Quote:
Originally Posted by NoWhErE
Technically you can do it. The main problem is re-writing the image filename every time.
This means you need to copy the placeholder.jpg to a new file, rename it, then display it.
|
Making a copy of the same image file doesn't make much sense...
Instead, I would create a php file, let's say, call it
placeholder.php.
- Add rewrite rule to .htaccess file:
RewriteRule image-(.*)\.jpg$ placeholder.php?slug=$1 [L]
- Create placeholder.php:
Takes input from a query like this:
placeholder.php?slug=this-is-the-url-slug.
Then, check if that url slug is a match with an entry from the SQL database.
If it's a match, print the new re-written image url (<img src='image-this-is-the-url-slug.jpg'>) else, just print (<img src='image-fallback.jpg'>).
Replace the - with spaces and you can include it as an alt tag as well.