View Single Post
Old 05-01-2022, 07:44 PM  
zijlstravideo
Confirmed User
 
zijlstravideo's Avatar
 
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
yourdomain.com/go-fuck-yourself.html will become go-fuck-yourself.jpg.

<?php
$myPage = explode('.',strtolower($_SERVER[REQUEST_URI]));
$myImage = trim(preg_replace("/[^a-zA-Z0-9\-]+/", "", $myPage[0]));
$myImage = $myImage . '.jpg';

// can also be: $myImage = 'files/images/' . $myImage . '.jpg';
// or whatever folder or image file format you want...

if (@getimagesize($myImage)) {
echo "<img src='$myImage'>";
} else {
// file doesn't exist, show placeholder
echo "<img src='files/images/placeholder.jpg'>";
}
die();
?>


I got a feeling there's even a faster way, but just like you, I'm too lazy to dive into the PHP docs 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