Is there a way to display a default image if there is no image added for that product instead of listing the product name?
Thanks,
Clint
Printable View
Is there a way to display a default image if there is no image added for that product instead of listing the product name?
Thanks,
Clint
The default is to show "No Picture Available" which is actually an image itself - no_picture.gif in the /images folder. So if you replaced that with an image of your choice it would show up any place the image doesn't exist.
Thanks. What about for products that have an image file included but can't find the file? Such as file misnamed?
Thanks,
Clint
Um ... that "listing the product name" is coming from the browser: when an image doesn't load, some browsers simply display the ALT text in the image's place.
Plus, you can't have a misnamed image when you upload your images via the Zen Cart admin console, because it stores exactly the image you upload.
I just needed something simliar, just wanted cart to show the no_picture image if a mispelt image name occured, or image was deleted off server etc by accident, so made changes as follows:
copy across main_product_image.php from includes/modules/ to your includes/modules/YOUR_TEMPLATE_NAME
then find
and underneath putCode:if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
then copy across product_listing.php from includes/modules/ to your includes/modules/YOUR_TEMPLATE_NAMECode:if (!file_exists(DIR_WS_IMAGES . $products_image)) {
$products_image ="no_picture.gif";
}
then find:
and underneath addCode:
if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
$lc_text = '';
} else {
then just below that you will find two occurances of codeCode:if (!file_exists(DIR_WS_IMAGES . $listing->fields['products_image'])) {
$products_listing_image = DIR_WS_IMAGES . "no_picture.gif";
}
else
{
$products_listing_image = DIR_WS_IMAGES . $listing->fields['products_image'];
}
to change toCode:'products_id=' . $listing->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH,
Code:'products_id=' . $listing->fields['products_id']) . '">' . zen_image($products_listing_image, $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH,
thats it.