2

我在电子邮件布局中有这个代码片段:

  <div>
    <?php echo $this->Html->image('Layouts/default/Logo.png', array(
      'alt' => 'Setin SRL',
      'url' => $this->Html->url(array('action' => 'index'), true)
    )); ?>
  </div>

然而这并不好。我可以通过url(array('action' => 'index'), true)

但是我也找不到任何可以为图像设置为 true 的参数。关于如何执行此操作的任何建议或解决方法?

编辑1: 基本上,我需要这个链接:成为Layouts/default/Logo.pngimg srchttp://www.something.com/Layouts/default/Logo.png

4

4 回答 4

1

我总是用

$this->Html->link($this->Html->image(...), $this->Html->url(array('action' => 'index'), true), array('escape'=>false));
于 2012-04-07T19:26:24.867 回答
1

我想这就是你要找的。

<?
echo $this->Html->image(Router::url('/') . 'Layouts/default/Logo.png');
?>
于 2012-04-09T21:40:59.297 回答
1

您正在寻找的可能是在方法实现中使用的HtmlHelper::assetUrlimage函数:

public function image($path, $options = array()) {
    $path = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.imageBaseUrl')));
    ...
于 2015-04-23T07:45:20.230 回答
0
$img = '<img src="http://some-img-link" alt="some-img-alt"/>';

$src = preg_match('/<img src=\"(.*?)\">/', $img);

echo $src;

我想src从 img 标签中获取值,也许是 alt 值

于 2012-07-10T03:51:34.600 回答