By using the .htaccess file, I can make any missing image on a page be replaced with a default ‘not found’ image. However, when this is done the replacement ‘not found’ image is stretched to the dimensions of the original missing image. I was wondering if anybody has a solution to this.

I was thinking the best method would be (probably through PHP) to make the ‘not found’ image be resized to the missing image’s dimensions set in the <img> tag. So bassicaly have a default 'not found' image and just add extra padding around the image to make it fit.

Any better ideas or ideas of how to do this?

Thanks

Member Avatar for diafol

You could do that with a

if(!file_exists($filepath))$filepath = 'images/default_nf.png';
...
<img src="<?php echo $filepath;?>" />

or similar...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.