Skip to content

Commit

Permalink
Enabling Asset.timestamp for HtmlHelper::image() making it consistent…
Browse files Browse the repository at this point in the history
… with Javascript::link().

Tests added.
Fixes #6170

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8078 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Mar 6, 2009
1 parent ffc537a commit c164be8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/html.php
Expand Up @@ -435,7 +435,7 @@ function image($path, $options = array()) {
} elseif ($path[0] === '/') {
$path = $this->webroot($path);
} elseif (strpos($path, '://') === false) {
if (Configure::read('Asset.timestamp') == true && Configure::read() > 0) {
if (Configure::read('Asset.timestamp') == true && Configure::read() > 0 || Configure::read('Asset.timestamp') === 'force') {
$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . IMAGES_URL . $path));
}
$path = $this->webroot(IMAGES_URL . $path);
Expand Down
13 changes: 11 additions & 2 deletions cake/tests/cases/libs/view/helpers/html.test.php
Expand Up @@ -240,8 +240,17 @@ function testImageTag() {

Configure::write('Asset.timestamp', true);

$result = $this->Html->image('logo.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/logo\.gif\?\d*/', 'alt' => '')));
$result = $this->Html->image('cake.icon.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));

$back = Configure::read('debug');
Configure::write('debug', 0);
Configure::write('Asset.timestamp', 'force');

$result = $this->Html->image('cake.icon.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));

Configure::write('debug', $back);
}
/**
* testStyle method
Expand Down

0 comments on commit c164be8

Please sign in to comment.