View Single Post
  #1  
Old 08-20-2006, 06:57 AM
 
mrkenzie mrkenzie is offline
 

Senior Member
  
Join Date: May 2006
Posts: 182
 

Default create thumbs from large image

This mod has been tested in 4.1.0. It will allow you to only upload a product image and display a thumb and multiple size images from one. So you do not have to upload a product image and a product thumb image. If a thumbnail image exists, then it will use it instead of the product image.

I did this because I did not want to upload product images and then have to create a new image for thumbs for each of my products. I wanted to buy the Telefirma mod, but does not work in 4.1.x yet and I did not know when it will be ready for 4.1.x. It took me about 20 hours to create this, so I figured I should share it and let others benefit from this also.

Where you are calling product_thumbnail.tpl, you can pass these parameters:

tmbn_height - height of image to be created
tmbn_width - width of image to be created
tmbn_link (true or false) - whether or not to make the image a link to the original size of the image

All of the parameters that the mod takes is listed in the link in step 1, you would just need to modify the product_thumbnail.tpl to accept the parameter and pass it to thumb mod.

Here are the steps:

1. Goto this site: http://www.cerdmann.com/thumb/ and download function.thumb.php and copy into your smarty -> plugins directory

2. Replace contents of skin1\product_thumbnail.tpl with

Code:
{* $Id: product_thumbnail.tpl,v 1.19 2005/11/17 06:55:36 max Exp $ *} {if $config.Appearance.show_thumbnails eq "Y"}{if $tmbn_path_p ne ''}{thumb file=$tmbn_path_p type=2 html="style='margin:5px;' alt='$product'" addgreytohint="false" width="$tmbn_width" height="$tmbn_height" extrapolate="false" link="$tmbn_link"}{elseif $tmbn_path_t ne ''} {thumb file=$tmbn_path_t type=2 html="style='margin:5px;' alt='$product'" addgreytohint="false" width="$tmbn_width" height="$tmbn_height" extrapolate="false" link="$tmbn_link"}{else}[img]{if $tmbn_url}{$tmbn_url}{else}{if $full_url}{$http_location}{else}{$xcart_web_dir}{/if}/image.php?type={$type|default:[/img]{/if}{/if}

3. This step modifies the product.php page so that when you are searching, it returns the path to the product image.
In include\func\func.product.php find the following:
Code:
if ($current_area == "C") { $left_joins['product_taxes'] = array( "on" => "$sql_tbl[product_taxes].productid = $sql_tbl[products].productid" ); $fields[] = "$sql_tbl[product_taxes].taxid";

and add this after:
Code:
if ($current_area != "A") { $left_joins['images_P'] = array( "on" => "$sql_tbl[images_P].id = $sql_tbl[products].productid" ); $fields[] = "$sql_tbl[images_P].image_path as "; }

4. This modification passes the product and thumb image paths to product_thumbnail.tpl
In Skin1\customer\main\product.tpl find the following:
Code:
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail" type="P"}

and replace with this:
Code:
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.image_x image_y=$product.image_y product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail" type="P" tmbn_path_p=$product.image_path_P tmbn_path_t=$product.image_path_T }

5. This step passes the product and thumb paths to the product_thumbnail.tpl file if use popup images is checked (in admin side).
In skin1\modules\Detailed_Product_Images\popup_image. tpl find this:

and replace it with this:

6. This step allows the thumb image to be created for the product listing page. If you are not using the DSEFU mod, then only find and replace what is in the else statement.
In skin1\customer\main\products.tpl find this:

and replace with this:

7. In include\search.php find this:
Code:
$left_joins['product_memberships'] = array( "on" => "$sql_tbl[product_memberships].productid = $sql_tbl[products].productid" );

and after that, add:
Code:
if ($current_area != "A") { $left_joins['images_P'] = array( "on" => "$sql_tbl[images_P].id = $sql_tbl[products].productid" ); $fields[] = "$sql_tbl[images_P].image_path as p_image_path"; }

8. This step gets the product image path for the recommended products - I modified my recommended products to show the product image, not just a link. If you do not show a product image in recommended products, then just skip this step.
In recommends.php find this:
Code:
if ($config["Recommended_Products"]["select_recommends_list_randomly"] == "Y" && count($query_ids) > 0) { $query = "SELECT $sql_tbl[products].* FROM $sql_tbl[products] WHERE $sql_tbl[products].productid IN ('".join("','",$query_ids)."')"; } else { $query = "SELECT DISTINCT sp2.productid, $sql_tbl[products].* FROM $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] AS sp2, $sql_tbl[products_categories], $sql_tbl[products], $sql_tbl[categories] LEFT JOIN $sql_tbl[category_memberships] ON $sql_tbl[category_memberships].categoryid = $sql_tbl[products_categories].categoryid WHERE sp1.productid='$productid' AND sp1.login=sp2.login AND sp2.productid!='$productid' AND $sql_tbl[products].productid=sp2.productid AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products].productid = $sql_tbl[products_categories].productid AND $sql_tbl[products_categories].main = 'Y' AND $sql_tbl[categories].categoryid = $sql_tbl[products_categories].categoryid AND $sql_tbl[categories].avail = 'Y' AND $sql_tbl[category_memberships].membershipid IN ('$user_account[membershipid]', 0) ".$avail_condition." ORDER BY $sql_tbl[products].product LIMIT ".$config["Recommended_Products"]["number_of_recommends"]; }

and replace with this:
Code:
if ($config["Recommended_Products"]["select_recommends_list_randomly"] == "Y" && count($query_ids) > 0) { $query = "SELECT $sql_tbl[products].*, $sql_tbl[images_P].image_path as p_image_path FROM $sql_tbl[products] LEFT JOIN $sql_tbl[images_P] on $sql_tbl[images_P].id=$sql_tbl[products].productid WHERE $sql_tbl[products].productid IN ('".join("','",$query_ids)."')"; } else { $query = "SELECT DISTINCT sp2.productid, $sql_tbl[products].*, $sql_tbl[images_P].image_path as p_image_path FROM $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] AS sp2, $sql_tbl[products_categories], $sql_tbl[products], $sql_tbl[categories] LEFT JOIN $sql_tbl[category_memberships] ON $sql_tbl[category_memberships].categoryid = $sql_tbl[products_categories].categoryid LEFT JOIN $sql_tbl[images_P] on $sql_tbl[images_P].id=$sql_tbl[products].productid WHERE sp1.productid='$productid' AND sp1.login=sp2.login AND sp2.productid!='$productid' AND $sql_tbl[products].productid=sp2.productid AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products].productid = $sql_tbl[products_categories].productid AND $sql_tbl[products_categories].main = 'Y' AND $sql_tbl[categories].categoryid = $sql_tbl[products_categories].categoryid AND $sql_tbl[categories].avail = 'Y' AND $sql_tbl[category_memberships].membershipid IN ('$user_account[membershipid]', 0)".$avail_condition." ORDER BY $sql_tbl[products].product LIMIT ".$config["Recommended_Products"]["number_of_recommends"]; }

9. This step passes the product image path to the product_thumbnail.tpl file for recommended products (upsell). Again, if you do not show the product images for recommended products, then skip this. Also, I have a tabs mod installed, so it will be a different file than listed and the code might be slightly different.

Find where you are calling product_thumbnail.tpl (using an include) and replace it with this:
Code:
{include file="product_thumbnail.tpl" productid=$recommends[num].productid image_x=$recommends[num].image_x image_y=$recommends[num].image_y product=$recommends[num].product tmbn_url=$recommends[num].tmbn_url id="product_thumbnail" tmbn_path_p=$recommends[num].p_image_path tmbn_link="false" tmbn_width="100"}

You should be done.

I will try to post some screen shots later.

Let me know if you have any questions or problems.
__________________
Mike Kenzie
X Cart Gold Ver. 4.1.3
X-RMA
X-AOM
X-Product Comparison
Reply With Quote