You are using the fanstactic Gregwar/ImageBundle code to manipulate your images on Symfony2 and twig.
But instead of rendering your website, you get this error on your apache error log file
1 | PHP Fatal error: Method Gregwar\\ImageBundle\\ImageHandler::__toString() must not throw an exception in /home/www/recette/app/cache/dev/classes .php on line 7426 |
or directly on your html genered code
1 2 | <img src=" Fatal error: Method Gregwar\ImageBundle\ImageHandler::__toString() must not throw an exception in /home/www/recette/app/cache/dev/classes.php on line 7426 |
this issue may be a rights problem on your cache drectory. By default, gregwar cache directory is on your web so, launch this command
1 | chmod 777 web /cache |
This error may also occur if the file doesn’t exist, for a clean code, add
1 2 3 | {% if file_exists ( 'uploads/' ~ site.id ~ '.jpg' ) %} {{ image(site.picture).resize(250, 50) }} {% endif %} |
or on twig code
1 2 3 | {% if site.has_picture %} {{ image(site.picture).resize(250 ,50) }} {% endif %} |
For more informations about file_exists, see here Symfony2 twig add new function file_exists