I would love to have a config setting (maybe only for devMode) which allows to set a dummy image file, which is used if the original asset is missing. Why? Because most space on my computer is taken by customer images I download to avoid getting exceptions about missing files when I am tracing bugs and therefor imported a production database on my dev system.
I know that this can be done on the developer side by using wrappers for the whole resizing methods or by using custom extension, but having this as a core feature would be so neat!
If you are importing the production database locally, have you tried creating a redirect in nginx/apache to load the production assets instead?
@wrux Thanks for your suggestion, but I think this will not help me because I get serverside exceptions which I would still get when using redirects, as they happen on the page request and not on the image request.
Just added a new brokenImagePath config setting, for Craft 3.5, which you can set to the server path of an image file that should be served on any 404 image response. For example, here鈥檚 how you can hook the front-end up to use Craft鈥檚 own broken image SVG:
'brokenImagePath' => '@app/icons/broken-image.svg',
Any alias could work here, including @webroot (the path to the folder that contains your index.php file).
Note that this will only affect requests that include image/* in the Accept header. Browsers will include that when loading an <img> src, but not when you access an image URL directly. So if you access an image URL directly in your browser, you鈥檒l still get the normal exception view or 404 page.
Most helpful comment
Just added a new
brokenImagePathconfig setting, for Craft 3.5, which you can set to the server path of an image file that should be served on any 404 image response. For example, here鈥檚 how you can hook the front-end up to use Craft鈥檚 own broken image SVG:Any alias could work here, including
@webroot(the path to the folder that contains yourindex.phpfile).Note that this will only affect requests that include
image/*in theAcceptheader. Browsers will include that when loading an<img>src, but not when you access an image URL directly. So if you access an image URL directly in your browser, you鈥檒l still get the normal exception view or 404 page.