1
我正在使用CakePHP。如何向CakePHP中的HTMLHelper中的图像方法添加属性到链接?
这行代码会产生<img>
标签:
$html->image('image.png', array('alt', 'Alternative text'));
,这将产生同样的事情,但它会使图像点击:
$html->image('image.png', array('alt' => 'Alternative text', 'url' => 'http://www.example.com'));
到目前为止,我明白,但如果我想为<a>
标记添加属性,我该怎么办?
这样做:
$html->image('image.png', array('alt' => 'Alternative text', 'url' => 'http://www.example.com/', 'class' => 'aClass'));
将属性添加到<img>
而不是<a>
。输出是这样的:
<a href="http://www.example.com/">
<img src="image.png" alt="Alternative text" class="aClass" />
</a>
但我想是这样的:
<a href="http://www.example.com/" class="aClasse">
<img src="image.png" alt="Alternative text" />
</a>
我试图做类似$html->link()
使用$html->image()
作为第一个参数,但没有奏效。
有什么想法?