mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Merge pull request #419 from radig/2.1
Fix HtmlHelper::link test and extend HtmlHelper::image (issue #2476)
This commit is contained in:
commit
7cfd27e7f6
2 changed files with 16 additions and 5 deletions
|
@ -315,18 +315,19 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
|
||||
$result = $this->Html->link($this->Html->image('../favicon.ico'), '#', array('escape' => false));
|
||||
$result = $this->Html->link($this->Html->image('../favicon.ico'), '#', array('escape' => false));
|
||||
$expected = array(
|
||||
'a' => array('href' => '#'),
|
||||
'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''),
|
||||
'img' => array('src' => 'img/../favicon.ico', 'alt' => ''),
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->image('../favicon.ico', array('url' => '#'));
|
||||
|
||||
$expected = array(
|
||||
'a' => array('href' => '#'),
|
||||
'img' => array('src' => 'preg:/img\/..\/favicon\.ico\?\d*/', 'alt' => ''),
|
||||
'img' => array('src' => 'img/../favicon.ico', 'alt' => ''),
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
@ -351,6 +352,10 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Html->image('/test/view/1.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => '')));
|
||||
|
||||
$result = $this->Html->image('test.gif', array('fullBase' => true));
|
||||
$here = $this->Html->url('/', true);
|
||||
$this->assertTags($result, array('img' => array('src' => $here . 'img/test.gif', 'alt' => '')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -739,8 +739,9 @@ class HtmlHelper extends AppHelper {
|
|||
|
||||
/**
|
||||
* Creates a formatted IMG element. If `$options['url']` is provided, an image link will be
|
||||
* generated with the link pointed at `$options['url']`. This method will set an empty
|
||||
* alt attribute if one is not supplied.
|
||||
* generated with the link pointed at `$options['url']`. If `$options['fullBase']` is provided,
|
||||
* the src attribute will receive full address (non-relative url) of the image file.
|
||||
* This method will set an empty alt attribute if one is not supplied.
|
||||
*
|
||||
* ### Usage
|
||||
*
|
||||
|
@ -766,6 +767,11 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
$path = $this->assetTimestamp($this->webroot($path));
|
||||
}
|
||||
|
||||
if (!empty($options['fullBase'])) {
|
||||
$path = $this->url('/', true) . $path;
|
||||
unset($options['fullBase']);
|
||||
}
|
||||
|
||||
if (!isset($options['alt'])) {
|
||||
$options['alt'] = '';
|
||||
|
|
Loading…
Add table
Reference in a new issue