问题
I have this code snippet in an email layout:
<div>
<?php echo $this->Html->image('Layouts/default/Logo.png', array(
'alt' => 'Setin SRL',
'url' => $this->Html->url(array('action' => 'index'), true)
)); ?>
</div>
However this is not ok. I can get the FULL url to the website through url(array('action' => 'index'), true)
But I can't find any paramater that I can set to true for image too. Any suggestion or workaround on how can I do this?
Edit 1:
Basically, I need this link: Layouts/default/Logo.png
to become http://www.something.com/Layouts/default/Logo.png
in the img src
回答1:
i always use
$this->Html->link($this->Html->image(...), $this->Html->url(array('action' => 'index'), true), array('escape'=>false));
回答2:
I think this is what you are looking for.
<?
echo $this->Html->image(Router::url('/') . 'Layouts/default/Logo.png');
?>
回答3:
What you are looking for is probably the HtmlHelper::assetUrl function that is used in the implementation of image
method:
public function image($path, $options = array()) {
$path = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.imageBaseUrl')));
...
回答4:
$img = '<img src="http://some-img-link" alt="some-img-alt"/>';
$src = preg_match('/<img src=\"(.*?)\">/', $img);
echo $src;
I want to get the src
value from the img tag and maybe the alt value
来源:https://stackoverflow.com/questions/10057491/how-can-i-get-full-link-to-an-image-in-the-img-tag-through-the-html-helper-imag