I need to display images that are stored outside of the project directory. Here's the structure :
- symfony project
- second project/
- /src/
- /assets/
- /images
Giving the direct path did not work. Like so : <img src="../../../second_project/src/assets/images/filename">
, using the {{asset ('direct_path')
didn't do the job either.
I'm currently trying to use a controller path to do so, it currently looks like this :
/**
* @Route("/admin/getphoto/{filename}", name="get_photo")
*/
public function getPhoto($filename) {
$path = realpath($this->getParameter('uploads_directory' . '/' . $filename));
return file($path, ['ContentType' => 'image/jpeg']);
}
with my template looking like this :
<img src="{{ path('get_photo', {'filename' : photo.tag} ) }}" alt="">