Replacing missing images with a default or placeholder... htaccess?
Posted: Thu Dec 30, 2010 4:17 pm
Hey folks,
I have some images that are dynamically generated from variable names in a module. Occasionally, one of them might not actually exist on the server yet, so I want a default image to appear in its place.
I've done some Googling and played about with htaccess, but can't make it work yet. I added this:
to the .htaccess file in /docs/
But it doesn't appear to be working.
The path to the image is correct in relation to the CMSMS root (I tried it in relation to the htaccess file too, that didn't work either). Do I need the/a htaccess file in a different place (such as the root)?
Any pointers?
Doing it with PHP seems like overkill...
I feel like there should be something built into CMSMS to achieve this; am I missing it?
Thanks!
I have some images that are dynamically generated from variable names in a module. Occasionally, one of them might not actually exist on the server yet, so I want a default image to appear in its place.
I've done some Googling and played about with htaccess, but can't make it work yet. I added this:
Code: Select all
RewriteEngine on
RewriteBase /cms/
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ /uploads/images/icon_default.png [L]
But it doesn't appear to be working.
The path to the image is correct in relation to the CMSMS root (I tried it in relation to the htaccess file too, that didn't work either). Do I need the/a htaccess file in a different place (such as the root)?
Any pointers?
Doing it with PHP seems like overkill...
I feel like there should be something built into CMSMS to achieve this; am I missing it?
Thanks!