From dce732770c7b091216574cb81f8ced1f0c9fc522 Mon Sep 17 00:00:00 2001 From: didix16 Date: Tue, 24 Jan 2017 11:28:37 +0100 Subject: [PATCH 1/2] Update ImageLocator.php Now search image not only in *images* folder inside Resources/public but also search inside *img* folder --- Templating/ImageLocator.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Templating/ImageLocator.php b/Templating/ImageLocator.php index 9273ed1..4599c4e 100644 --- a/Templating/ImageLocator.php +++ b/Templating/ImageLocator.php @@ -34,12 +34,14 @@ public function __construct(Kernel $kernel) public function getImagePath($logicalImageName) { $pos = strpos($logicalImageName, ':'); + + $exists = is_dir($this->kernel->getRootDir() . '/Resources/public/images/'); // add support for ::$imagePath syntax as in twig // @see http://symfony.com/doc/current/book/page_creation.html#optional-step-3-create-the-template if($pos === false || $pos === 0) { - return $this->kernel->getRootDir() . '/Resources/public/images/' . ltrim($logicalImageName, ':'); + return $this->kernel->getRootDir() . '/Resources/public/'.(!$exists ? 'img/' : 'images/') . ltrim($logicalImageName, ':'); } $bundleName = substr($logicalImageName, 0, $pos); @@ -48,6 +50,5 @@ public function getImagePath($logicalImageName) $bundle = $this->kernel->getBundle($bundleName); $bundlePath = $bundle->getPath(); - return $bundlePath.'/Resources/public/images/'.$imageName; - } + return $bundlePath.'/Resources/public/'.(!$exists ? 'img/' : 'images/') .$imageName; } From d5eb8f1c6e3164d25567a6d0536bb94fc19b749a Mon Sep 17 00:00:00 2001 From: didix16 Date: Tue, 24 Jan 2017 12:15:50 +0100 Subject: [PATCH 2/2] Update ImageLocator.php Forgotten close bracket... --- Templating/ImageLocator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Templating/ImageLocator.php b/Templating/ImageLocator.php index 4599c4e..45528fc 100644 --- a/Templating/ImageLocator.php +++ b/Templating/ImageLocator.php @@ -51,4 +51,6 @@ public function getImagePath($logicalImageName) $bundlePath = $bundle->getPath(); return $bundlePath.'/Resources/public/'.(!$exists ? 'img/' : 'images/') .$imageName; + + } }