CakePHP中的图像链接 [英] Image link in CakePHP
本文介绍了CakePHP中的图像链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想制作图片链接,因为我写了以下代码:
I want to make an image link, for that I wrote the following code:
<?php echo $this->Html->link(
$this->Html->image('logo.png', array('height' => '100', 'width' => '100','escape' => false)),
array('controller'=>'officers','action'=>'home'));
?>
它不显示图像,而是显示链接中的以下行: p>
it doesn't show the image, instead of image it shows the following line in link:
<img src="/event_management/img/logo.png" height="100" width="100" alt="" />
链接正常工作。如何显示图像?
the link is working. How can I show the image?
推荐答案
请尝试移除 escape => false
,并在您的图片之前添加斜杠作为其相对于您的 app / webroot
文件夹:
try removing escape => false
from your image, and add slash before your image as its relative to your app/webroot
folder , as:
echo $this->Html->link(
$this->Html->image('/<your-img-folder>/logo.png',array('height' => '100', 'width' => '100')),
array(
'controller' => 'zones',
'action' => 'index'
), array('escape' => false)
);
这篇关于CakePHP中的图像链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文