0

I tried to render something like this using html helper:

<a href="#" class="some-class"><img src="url/to/image.png" alt="alt-tag" /></a>

I write this in my .ctp file:

 <?php
echo $this->Html->link($this->Html->image("image.png", array("alt" => "alt-tag")),"#", array('class' => 'some-class'));
?>

But in browser, image was not displaying but simple plain text :

<img src="/url/to/image.png" alt="alt-tag" />

I did inspect element, where everything look as what I wanted to render. I tried to edit it live, so I selected edit as html option in inspect element. I surprised to see following code:

<a href="#" class="some-class">&lt;img src="/url/to/image.png" alt="alt-tag" /&gt;</a>

Please not that insted of < and > it was &lt; and &gt;.

I couldn't figure out what is the problem. (I am new to cakephp).

4

1 回答 1

7

使用escape属性为 False

前任:

echo $this->Html->link($this->Html->image("image.png", array("alt" => "alt-tag")),"#", array('class' => 'some-class', 'escape' => false));
于 2013-10-09T06:54:39.193 回答