2012-02-25 152 views
2

,我有以下的CakePHP代碼添加類圖像鏈接

<?php echo $this->Html->image('products/'.$product['Product']['picture'],array('url'=>'/img/products/thumb.big.'.$product['Product']['picture'])); ?> 

上面的代碼產生follwoing HTML:

<a href="/oscar-demo/cakephp/img/products/thumb.big.hs_2010_13_a_1920x1200_wallpaper.jpg"> 
    <img alt="" src="/oscar-demo/cakephp/img/products/hs_2010_13_a_1920x1200_wallpaper.jpg"> 
</a> 

但我想在a添加一個類。我該怎麼做?

回答

2

可以使用內部鏈接的圖像:

echo $this->Html->link($this->Html->image('products/'.$product['Product']['picture']), '/img/products/thumb.big.'.$product['Product']['picture'], array('class' => 'css-class', 'escape' => false); 
0

我已經創建了的style.css類deleteImg和鏈接的圖像在那個類中,並簡單地將類應用於該鏈接。 ('',array('controller'=>'Mycont','action'=>'deletepic',$ id),數組('confirm'=>'Are你確定要刪除圖像?','class'=>'deleteImg'));