Check for image file, not there, display default blank.gif

General ShopSite user discussion

Check for image file, not there, display default blank.gif

Postby dmsid » Sat Aug 30, 2008 6:49 am

Like you I have thousands of products. We make the image file match the SKU number.

Product NT19432 has a picture file called NT19432.jpg that we have Shopsite create in three sizes.

Is there a way, Shopsite or Javascript, or ??? to look to see if the file exists on the server and if it does NOT exist on the server to display a file called blank.gif.

[if filename exists]
Do regular display of image
[else]
Display blank.gif
[endif]

Or just not display the file and do not display blank.gif

[if filename exists]
Do regular display of image
[endif]


This would reduced our [X] broken link images that are displayed when someone forgets to make a NT19432.jpg that is a blank. It would save a lot of time having to make these files for new products with no image.

And no we do not want to remove the ART#### from the graphic field, because when we do get an image we do not want to add data back in. New products are added from a datafile will all the pieces filled in ready to go.

All the best,
-Jon
dmsid
 
Posts: 29
Joined: Tue Aug 29, 2006 10:15 am

Postby Jim » Sat Aug 30, 2008 9:35 am

You can check if an image is assigned to a product by using [-- if product.graphic --] this will see if the database contains a value for the image. However, I don't think there is a way to see if the image actually exists on the server.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

That is what I thought

Postby dmsid » Sat Aug 30, 2008 10:55 am

Well a simple check for file in the next release with an option in the images config would solve this. LOL
dmsid
 
Posts: 29
Joined: Tue Aug 29, 2006 10:15 am

Postby Jim » Sat Aug 30, 2008 12:12 pm

When you are on the products screen and try to save if you have an image assigned but the image doesn't exist you get an error. You can't continue until you either select a different image or set it to None. So the check is there already. If you upload your product information then this check is not done.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

A Check on the way out.

Postby dmsid » Sat Aug 30, 2008 1:28 pm

True, but we do all our major updates with Excel, even minor ones, so a check on the way out would be sweet.

That is why it is nice to be able o get under the engine on some software.

Also, if you are not using the dropdown menu for picking a file you can type anything you want there in the graphic name and it will not check for you as you save.

Thanks again for all your input.

JDK
dmsid
 
Posts: 29
Joined: Tue Aug 29, 2006 10:15 am

Postby robm » Sat Aug 30, 2008 2:56 pm

If you're on a Linux/FreeBSD server with Apache, you could place a .htaccess file in your media directory with a mod_rewrite rule to display a default graphic when an image is missing. An example:

Code: Select all
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.gif$ /replacement.gif [L]


This will output replacement.gif for any .gif that is missing. You can add .jpg with:

Code: Select all
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.jpg$ /replacement.gif [L]
robm
 
Posts: 463
Joined: Fri Aug 04, 2006 5:46 pm
Location: Connecticut


Return to User Forum

Who is online

Users browsing this forum: No registered users and 69 guests