使用HTML Helper创建图像链接 [英] Creating Image link with HTML Helper
本文介绍了使用HTML Helper创建图像链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Laravel 4的HTML帮助程序创建一个图像链接。但它似乎并没有真正起作用。我有这行代码
I'm trying to create an image link with the HTML helper of Laravel 4. But it seems that isn't really working. I have this line of code
{{ HTML::link("#", HTML::image("img/logo.png", "Logo") ) }}
但是只输出这样的strin:
But that just outputs a strin like this:
<img src="http://localhost/worker/public/img/logo" alt="Logo">
怎么回事。??
推荐答案
你可能需要:
<a href="#">{{ HTML::image("img/logo.png", "Logo") }}</a>
因为,link()使用实体来转义标题:
Because, link() uses entities to escape the title:
public function link($url, $title = null, $attributes = array(), $secure = null)
{
$url = $this->url->to($url, array(), $secure);
if (is_null($title) or $title === false) $title = $url;
return '<a href="'.$url.'"'.$this->attributes($attributes).'>'.$this->entities($title).'</a>';
}
制作此源代码:
"<a href="#"><img src="http://localhost/img/logo.png" alt="Logo"></a>"
这篇关于使用HTML Helper创建图像链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文