2013-03-23 83 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的原因,這樣更容易閱讀。