2013-03-23 49 views
1

蛋糕,我们可以在图像中添加网址()这样的:
$this->Html->image('image src...', array('url' => 'some address...');
和输出是:
<a href="some address..."><img src="image src..." /></a>CakePHP的HTML辅助imgage链接

如何将类和其他属性添加到a标记?

+1

只要你需要更多的功能,你就可以更好地使用链接和图像功能。 – AD7six 2013-03-23 22:31:13

+0

Okey,谢谢你的回复,我用link()和image(); – kicaj 2013-03-23 22:33:00

回答

6
echo $this->Html->link(
    $this->Html->image($imageSrc, array(
     'class'=>'class_of_image', 
     'height' => '50', 
     'width' => '100', 
     'alt' => 'awesome close-up of me eating pizza' 
    )), 
    array(
     'controller' => 'your_controller', 
     'action' => 'the_action' 
    ), 
    array(
     'class' => 'class_of_anchor', 
     'escape' => false //to allow the image tag within the link 
    ) 
); 

随意将此任何/所有部分组合成一行 - 但对于StackOverflow的原因,这样更容易阅读。