I don't know if there is much benefit for it but :
PHP Code:
<?php
$placeholder_path = __DIR__ . "/placeholder.jpg";
$myPage = explode('.',strtolower($_SERVER[REQUEST_URI]));
$myImage = trim(preg_replace("/[^a-zA-Z0-9\-]+/", "", $myPage[0]));
$alt = $myImage;
$myImage = $myImage . '.jpg';
$new_path = __DIR__ . "/$myImage";
if (@getimagesize($new_path )) {
echo "<img src='$myImage'>";
} else {
$placeholder_image = @file_get_contents($placeholder_path);
$file = fopen("$new_path","w+");
if (flock($file,LOCK_EX)) {
fwrite($file,$placeholder_image);
fflush($file);
flock($file,LOCK_UN);
} else {
echo "Error locking file!";
}
fclose($file);
echo "<img src=\"$myImage\" alt=\"$alt\">";
}
?>
