Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Merge 07030bf into e566dd7
Browse files Browse the repository at this point in the history
  • Loading branch information
skie committed Apr 9, 2019
2 parents e566dd7 + 07030bf commit cdbd9df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/View/Helper/ImageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ protected function _getHash($version, $image) {
public function imageUrl($image, $version = null, $options = []) {
$fileInfo = pathinfo($image['path']);
$hash = $this->_getHash($version, $image);
$version = $fileInfo['dirname'] . DS . $fileInfo['filename'] . '.' . $hash;
$version = $fileInfo['dirname'] . DS . $fileInfo['filename'];
if ($hash !== null) {
$version .= '.' . $hash;
}

if (!empty($fileInfo['extension'])) {
$version .= '.' . $fileInfo['extension'];
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/View/Helper/ImageHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public function testImageUrl() {

$result = $this->Image->imageUrl($image, 't150', ['pathPrefix' => '/src/']);
$this->assertEquals('/src/test/path/testimage.c3f33c2a.jpg', $result);


$result = $this->Image->imageUrl($image, null, ['pathPrefix' => '/src/']);
$this->assertEquals('/src/test/path/testimage.jpg', $result);
}

/**
Expand Down

0 comments on commit cdbd9df

Please sign in to comment.