PDA

View Full Version : Best way to fix image that is not there.



michael_gersitz
02-14-2007, 07:26 PM
I am working on a script that copies thumbnails onto my site. The problem is, for some entrys in the database, the thumbnail will not copy onto my site for some reason leaving an ugly image with a red x in it.

Is there a simple way to stop this? By switching out the dead url, with a "no image" thumbnail url?

Thanks In Advance!

michael_gersitz
02-14-2007, 07:26 PM
Oh, by the way, I am using PHP.

agua
02-14-2007, 08:52 PM
One site work on has something similar where a default image is used if no image is found - here's the code:


if (empty($image_out)) {
$result = db_query("select image, image_path, image_type from $sql_tbl[thumbnail] where id='$id'");
if (db_num_rows($result))
list($image, $image_path, $image_type) = db_fetch_row($result);
else {
header("Content-type: image/gif");
func_readfile($default_image, true);
exit;
}
I can't help you any further as I haven't got much of a clue with php :p

rpanella
02-15-2007, 04:58 PM
You could use the PHP function file_exists($filename) to check if the thumbnail file exists on your server and if not display the default image.
________
YAMAHA VIRAGO 1100 (http://www.yamaha-tech.com/wiki/Yamaha_Virago_1100)