我想使用的$html->image(...)辅助函数在CakePHP中输出的图像,但我需要它来产生一个img使用标签的绝对而非相对URL(生成的HTML将被下载并通过电子邮件发送轮公司通讯).这可能吗?
它没有记录,但我注意到源代码,该image函数可以将数组作为其第一个参数.我并不完全清楚如何使其工作 - 这种方式的天真尝试产生相对于当前页面而不是webroot/img文件夹内的图像URL .
JD *_*cks 29
在CakePHP 1.x中,方法是:
$this->Html->image($this->Html->url('/path_to_image/image.png',true));
Run Code Online (Sandbox Code Playgroud)
在CakePHP 2.x中,方法是:
$this->Html->image('/path_to_image/image.png', array('fullBase' => true));
Run Code Online (Sandbox Code Playgroud)
小智 9
正确的方法是在CakePHP 2.x中:
<?php
echo $this->Html->image("logo.png", array('fullBase' => true));
Run Code Online (Sandbox Code Playgroud)
代码直接来自食谱:http: //book.cakephp.org/2.0/en/core-libraries/helpers/html.html
| 归档时间: |
|
| 查看次数: |
15740 次 |
| 最近记录: |