From 9848c6de54dedff5eb647e0761e9f3b8859d076a Mon Sep 17 00:00:00 2001 From: Yevgeny Tomenko Date: Sat, 6 Apr 2019 00:12:43 +0300 Subject: [PATCH 1/2] fix url generation in cake if hash is empty --- src/View/Helper/ImageHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/View/Helper/ImageHelper.php b/src/View/Helper/ImageHelper.php index 9cc90d7b..d6e63f64 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']; From d429c39bafc2eaf811472c7d5b07b89394a16ce4 Mon Sep 17 00:00:00 2001 From: Yevgeny Tomenko Date: Sat, 6 Apr 2019 00:23:43 +0300 Subject: [PATCH 2/2] code cleanup --- src/View/Helper/ImageHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View/Helper/ImageHelper.php b/src/View/Helper/ImageHelper.php index d6e63f64..934d1a53 100644 --- a/src/View/Helper/ImageHelper.php +++ b/src/View/Helper/ImageHelper.php @@ -93,7 +93,7 @@ public function imageUrl($image, $version = null, $options = []) { $fileInfo = pathinfo($image['path']); $hash = $this->_getHash($version, $image); $version = $fileInfo['dirname'] . DS . $fileInfo['filename']; - if ($hash != null) { + if ($hash !== null) { $version .= '.' . $hash; }