Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

show no-pic.gif if img not exsist?


stClem

Recommended Posts

I have uploaded a lot of products and images. Around 8500 products and around 7500 images. As you can see there is around 1000 products who dont have a image.

 

To make the image to go to the products it has the same name as product model. All products have images in the database, and the products who is missing images in the image folder only have a X on the product list. As expectet when the image dosnt exsit.

 

As you can understand, its a lot of work to find the 1000 products whitout picture, and change it to no-img or some other standard picture.

 

Is there any add ons or anything else wo can check if images exsist, and if it do, show the picture. If it not exsist, show no-pic.gif.

Link to comment
Share on other sites

In html_output.php at the start of the tep_image function add:

if (!file_exists($src) || empty($src) || ($src == DIR_WS_IMAGES)) $src = DIR_WS_IMAGES . 'no-pic.gif';

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

If @spooks's code change doesn't work for you, an alternative would be to check in your .htaccess file for a reference to a non-existent graphics file, and redirect the request to a standard "no pic" image file.

 

I haven't tried it, but it might be something like

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME) !-d
RewriteCond %{REQUEST_URI}  ^/catalog/images
RewriteRule  .*\.(jpg|jpeg|gif|png|bmp)$ /catalog/images/no-pic.gif  [NC]

Season to taste. What it's supposed to do is to catch references to non-existent files (and directories) and if the request is for your images directory, if it's a reference to an image file replace it by no-pic.gif.

 

Note that osC keeps most of its image files (such as for the logo) in this directory, so anything missing there will likely also get the "no-pic.gif" image file served up.

Link to comment
Share on other sites

In html_output.php at the start of the tep_image function add:

if (!file_exists($src) || empty($src) || ($src == DIR_WS_IMAGES)) $src = DIR_WS_IMAGES . 'no-pic.gif';

 

Thanks, working.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...