diff --git a/src/View/Helper/ImageHelper.php b/src/View/Helper/ImageHelper.php index 9cc90d7b..934d1a53 100644 --- a/src/View/Helper/ImageHelper.php +++ b/src/View/Helper/ImageHelper.php @@ -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']; diff --git a/tests/TestCase/View/Helper/ImageHelperTest.php b/tests/TestCase/View/Helper/ImageHelperTest.php index 5aaaec90..7ac766e3 100644 --- a/tests/TestCase/View/Helper/ImageHelperTest.php +++ b/tests/TestCase/View/Helper/ImageHelperTest.php @@ -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); } /**