Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Templating/ImageLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -48,6 +50,7 @@ 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;

}
}