ecclesr Posted June 2, 2007 Posted June 2, 2007 I have just applied contribution to "replace the ugly red-x" contribution http://www.oscommerce.com/community/contri...ons,1729/page,6 But nothing happens I am still getting red-x -has anyone managed to get this contribution to work I am developing on the windows platform Your help is appreciated My code in html_output.php is //// // The HTML image wrapper function function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { return false; } $img=true; if ($src == "images/"){ $img = false; $src = "images/noimg.jpg"; } // alt is added to the img tag even if it is null to prevent browsers from outputting // the image filename as default $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title=" ' . tep_output_string($alt) . ' "'; } if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { if ($image_size = @getimagesize($src)) { if (empty($width) && tep_not_null($height)) { $ratio = $height / $image_size[1]; $width = $image_size[0] * $ratio; } elseif (tep_not_null($width) && empty($height)) { $ratio = $width / $image_size[0]; $height = $image_size[1] * $ratio; } elseif (empty($width) && empty($height)) { $width = $image_size[0]; $height = $image_size[1]; } } elseif (IMAGE_REQUIRED == 'false') { return false; } } if (tep_not_null($width) && tep_not_null($height) && $img) { $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; } if (tep_not_null($parameters)) $image .= ' ' . $parameters; $image .= '>'; return $image; }
Nullachtfuffzehn Posted June 2, 2007 Posted June 2, 2007 At first I'd check which image is tried to be displayed. Maybe a typo within the filename of the noimg.jpg. Make sure it is located in the specified directory and it's filename is the same as in the script. To me it would sound better if the "images/" statement would be replaced with DIR_WS_IMAGES to make sure the contribution also works if you use another path to your pics.
ecclesr Posted June 3, 2007 Author Posted June 3, 2007 Manfred - Thank you for your reply I found since I posted the topic that the the coding is working in some circumstance but not others In the case of category/sub categories if the image is missing the expected default noimg.jgp is being displayed Where I am not seeing the expected noimg.jgp instead I see the red X is the what new box where the product is missing the its image and when that product is selected html_output.php Code now is // The HTML image wrapper function function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { return false; } $img=true; if ($src == DIR_WS_IMAGES){ $img = false; $src = "images/noimg.jpg"; } // alt is added to the img tag even if it is null to prevent browsers from outputting // the image filename as default $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title=" ' . tep_output_string($alt) . ' "'; } if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { if ($image_size = @getimagesize($src)) { if (empty($width) && tep_not_null($height)) { $ratio = $height / $image_size[1]; $width = $image_size[0] * $ratio; } elseif (tep_not_null($width) && empty($height)) { $ratio = $width / $image_size[0]; $height = $image_size[1] * $ratio; } elseif (empty($width) && empty($height)) { $width = $image_size[0]; $height = $image_size[1]; } } elseif (IMAGE_REQUIRED == 'false') { return false; } } if (tep_not_null($width) && tep_not_null($height) && $img) { $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; } Thanking you in advance for your help
Nullachtfuffzehn Posted June 3, 2007 Posted June 3, 2007 So you might check the properties of the image that is not displayed on the mentioned boxes to check out what source is given there. I can imagine that the parameters are different somehow and therefore the pic is not displayed. Let me know or give me a link.
swcharlie Posted April 20, 2011 Posted April 20, 2011 Hi there I am looking for a contribution similar to this one, but product and categories should have different default images. For example, all products without images should have the noimg.png image, but the categories/subcategories should just have a picture of an "unopened" folder. Does anyone know of such a contribution, or how to code something like that? Your help will be appreciated. Regards Schalk :D
swcharlie Posted April 21, 2011 Posted April 21, 2011 Hi there I am looking for a contribution similar to this one, but product and categories should have different default images. For example, all products without images should have the noimg.png image, but the categories/subcategories should just have a picture of an "unopened" folder. Does anyone know of such a contribution, or how to code something like that? Your help will be appreciated. Regards Schalk :D Does anyone maybe have a solution?? :blink:
swcharlie Posted December 7, 2011 Posted December 7, 2011 Hi there I finally got it sorted. All I had to do was change the following in the index.php file located in the store root directory: echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; to echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . 'Categorydefaultimage.jpg', $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { This may not link back to the admin settings, but atleast it suits my needs. Hope this helps anybody :D
OSC-Sevilla Posted December 9, 2011 Posted December 9, 2011 i did this: index.php at around line 96. <div class="padding">'. "\n"; $prods_content .= ' <ul class="sub_categories">'. "\n"; while ($categories = tep_db_fetch_array($categories_query)) { if ($categories['categories_image'] ==''){$categories['categories_image']=DEFAULT_CATEGORY_IMAGE;}; $rows++; $cPath_new = tep_get_path($categories['categories_id']); $p_name = '<span><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . $categories['categories_name'] . '</a></span>'; $p_pic = '<a class="prods_pic_bg" href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '" style="width:'.(SUBCATEGORY_IMAGE_WIDTH).'px;height:'.(SUBCATEGORY_IMAGE_HEIGHT).'px;">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . ''; add this line: if ($categories['categories_image'] ==''){$categories['categories_image']=DEFAULT_CATEGORY_IMAGE;}; i have added a module in admin to change the filename for easy upadates. both product images and category images sql: INSERT INTO `configuration` VALUES(89, 'Default Product Image', 'DEFAULT_PRODUCT_IMAGE','', 'If no product image is detected - Upload your default image to IMAGES directory - enter the filename and extension below (e.g. default_product_image.jpg):',4, 32, NULL, '2011-05-27 02:27:53', NULL, NULL); INSERT INTO `configuration` VALUES(90, 'Default Category Image', 'DEFAULT_CATEGORY_IMAGE','', 'If no category image is detected - Upload your default image to IMAGES directory - enter the filename and extension below (e.g. default_category_image.jpg):',4, 33, NULL, '2011-05-27 02:27:53', NULL, NULL);
Recommended Posts
Archived
This topic is now archived and is closed to further replies.