View Single Post
Old 05-02-2022, 09:00 AM  
zijlstravideo
Confirmed User
 
zijlstravideo's Avatar
 
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
Quote:
Originally Posted by NoWhErE View Post
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.
__________________
Contact: email
zijlstravideo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote