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

Commit

Permalink
Merge pull request #188 from skie/2.0
Browse files Browse the repository at this point in the history
fix url generation in cake if hash is empty
  • Loading branch information
burzum authored Apr 11, 2019
2 parents e566dd7 + 709582f commit e0cc17e
Show file tree
Hide file tree
Showing 2 changed files with 7 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
3 changes: 3 additions & 0 deletions tests/TestCase/View/Helper/ImageHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ 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 e0cc17e

Please sign in to comment.