X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   free Dynamic Images module released (https://forum.x-cart.com/showthread.php?t=41912)

PHPdev 09-27-2008 12:21 PM

Re: free Dynamic Images module released
 
tomcoleman,

I just installed a clean version of X-Cart 4.1.11 and was able to get this module working. I did have to code all the changes and run the DB script by hand, but since there are only three files to modify it was not to bad.

I'm not sure how much you know so I'll start basic, if this is below you, then please do not take it as an insult...

The default_image.gif is what X-cart uses when an image can not be found, unless you changed this image in the image settings of the admin. Therefore it seems as if you may have not done the coding by hand correctly.

The only thing I had to change to get this working was on the product.tpl I had to use $product.image_url instead of $product.thumb_url as the img src when displaying the image.

Not sure what X-carts default is on this page to show the thumb again or the actual product image... I did not see the thumbnail available to display in the $product options.

Hope this helps...

JWait 10-18-2008 02:46 PM

Re: free Dynamic Images module released
 
Quote:

Originally Posted by PHPdev
tomcoleman,

Not sure what X-carts default is on this page to show the thumb again or the actual product image... I did not see the thumbnail available to display in the $product options.

Hope this helps...


X-cart by default on the individual product page will display the product image (if there is one), then the thumbnail (if there is one and there is no product image), and finally default_image.gif (if there is no images defined).

xtestedx 10-25-2008 04:44 PM

Re: free Dynamic Images module released
 
does anyone know what you have to modify to get this working with detailed images>?

dgreen 10-28-2008 04:25 PM

Re: free Dynamic Images module released
 
Jon installed the dynamic image mod for me in the summer but I just noticed that when there is no image for the product, It shows the default_image.gif image, but it also shows an error:
Smarty error: thumb: image file "/default_image.gif" does not exist in /home/dgreen/public_html/Smarty-2.6.19/Smarty.class.php on line 1092

What can I do about this? When there is an image, all looks fine.
Any ideas?

PHPdev 10-29-2008 07:24 AM

Re: free Dynamic Images module released
 
X-cart looks to the default_image.gif when there is no image, sounds like this file is missing or misplaced. On a cart with out dynamic images installed mine resides in the root of the cart directory.

Is that file there?

dgreen 10-29-2008 11:05 AM

Re: free Dynamic Images module released
 
it's in the root folder.
Here is the code from my product.tpl page:


{* PHP Site Solutions - Dynamic Images *}
{if $active_modules.PHPSS_Dynamic_Images ne ""}
{assign var=phpss_dyn_img_width value=$config.PHPSS_Dynamic_Images.phpss_dyn_img_p rodtpl_img_width}
{/if}
{* / PHP Site Solutions - Dynamic Images *}

{if $active_modules.Detailed_Product_Images ne "" && $config.Detailed_Product_Images.det_image_popup eq 'Y' && $images ne '' && $js_enabled eq 'Y'}
{include file="modules/Detailed_Product_Images/popup_image.tpl"}
{elseif $product.force_image_type eq 'W' && $product.variantid}
{* PHP Site Solutions - Dynamic Images *}
{include file="product_thumbnail.tpl" productid=$product.variantid image_x=$phpss_dyn_img_width|default:$product.imag e_x product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail" type="W"} 
{* / PHP Site Solutions - Dynamic Images *}
{else}
{* PHP Site Solutions - Dynamic Images *}
{include file="product_thumbnail.tpl" productid=$product.productid image_x=$phpss_dyn_img_width|default:$product.imag e_x product=$product.product tmbn_url=$product.tmbn_url id="product_thumbnail" type="P"} 
{* / PHP Site Solutions - Dynamic Images *}
{/if}
{if $active_modules.Magnifier ne "" && $config.Magnifier.magnifier_image_popup eq 'Y' && $zoomer_images ne '' && $js_enabled eq 'Y'}
{include file="modules/Magnifier/popup_magnifier.tpl"}
{/if}

Thank you
Gitty

benz 11-13-2008 09:29 PM

Re: free Dynamic Images module released
 
I've had this problem too - I believe it occurs on sites that do not have their store in the root directory, the problem seems to come from how the path for default_image is calculated, the default image path gets passed to the thumbnail function as something like /store/default_image.gif rather than "http://somedomain.com/store/default_image.gif", the file_exists() check then can't find the image and throws a smarty error around line 283.

I threw in a quick hack to suppress the error message if the thumbnail path started with a /. The rest remains unchanged, as skip_thumb is still set true it will jump through the rest of the code and just return the original thumbnail path, xcart then looks happy.

Having done this nastily I'd love to see the RIGHT way to fix it, as this felt really dirty :oops:
...and I'm sure it will bite me in the near future....

In function.thumb_imp.php around line 283 change:
PHP Code:

$smarty->trigger_error('thumb: image file "' $params['file'] . '" does not exist'); 

to
PHP Code:

# benz - nasty hack to suppress the error and skip thumb if its  default_image issue
if( !preg_match('/^\//',$params['file'])) $smarty->trigger_error('thumb: image file "' $params['file'] . '" does not exist');
#/benz 


PS the line break in the code snippet above happened right in the middle of the match part of the regular expression (which is kind of important!), it should read !preg_match('/^\//',.......

dgreen 11-16-2008 06:10 AM

Re: free Dynamic Images module released
 
Thanks for the reply, but I don't seem to have the file function.thumb_imp.php .
Is it in the include/func directory? all of my files there start with func and NOT function.
Is it somewhere else?

Thank you
Gitty

benz 11-19-2008 03:20 AM

Re: free Dynamic Images module released
 
@dgreen

You'll find this file in:
your store directory
/include/templater/plugins

This file is the smarty plugin for the image generator - if you don't have this file then that could be the problem!

There's not actually that much required in the tpl files to make use of this, all they are doing is gathering up images to pass to this file.

From the install package the only truly important thing is the two extra .php files and the writable cache directory for the images - if you're having problems using this on different versions of xcart just try calling the "thumb" smarty function and pass it the path for an image you know exists to check if it works

eg in a tpl file somewhere include:
PHP Code:

{thumb file="images/somebigfile.jpg" width="150" link="false"

You should get back a thumbnail 150px wide. If you don't then you have a problem with the install of the 2 php files or the images/cache directory.

benz 11-26-2008 02:33 AM

Re: free Dynamic Images module released
 
One cautionary note, while this all works really well - and I've even now tweaked our admin screens, variants and detailed images to use this with lytebox as well cause we love it so much - at some point uploading a too large image will break things.

We had a client upload a 1.8mb, 300dpi, 1980x3000 jpeg and the entire category that the product was in went missing - you click the category and you get a blank screen. Downsized the image and everything went fine (Images on the file system)

I must admit I haven't checked further yet to see if it was Xcart, the mod or something else that crashed it, but I've got my eye on it now 8O


All times are GMT -8. The time now is 09:01 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.