X-Cart Mods, X-Cart Addons - WebsiteCM
Did you know...
You earn Customer Loyalty Points with every purchase for discounted future orders!
X-Cart Excellence eZine
Subscribe for proven tips and special discounts!
Cart is empty
X-Cart Services
X-Cart Customization X-Cart Optimization
X-Cart Mods
Recommended Packages Must Have Mods Reseller Program
Filter Mods By Version
Mods By Purpose
X-Cart Administration X-Cart Packages X-Cart Appearance X-Cart Conversion X-Cart Customers X-Cart Integration X-Cart Marketing X-Cart Navigation X-Cart Search X-Cart SEO X-Cart Shopping Feeds X-Cart Upselling X-Cart Templates
Mods By Firm
WebsiteCM BCSE Firetank

WebsiteCM on Twitter

Use X-Cart .jpg thumbnails for speed and SEO

Use X-Cart .jpg thumbnails for speed and SEO
Category: X-Cart Tutorials
Posted: Apr 13, 2010
Comments: 8 [Read/Post]
Synopsis: By default x-cart auto-generates png thumbnails, but using jpg's can improve your sites speed and SEO. This tutorial will show you how to create x-cart jpg thumbnails.

When creating x-cart product images, your typical file extension choices are JPG, GIF or PNG. GIF and PNG formats are ideal when creating logos, icons, and other types of images with a limited number of colors and/or when using a transparent background. JPG formats are ideal when creating photographic type images such as product images, making it typically the ideal choice for x-cart product and thumbnail images.

When using x-cart to auto-generate a thumbnail, x-cart outputs a PNG file. This PNG file will usually be very large in file size making your site load slower, and PNG files are less likely to get picked up in Google's image search than a JPG. With the changes outlined in this tutorial, you can easily auto-generate high quality JPG thumbnail images with a file size many times smaller than the generated PNGs.

Open include/func/func.gd.php

Find:

return func_gd_wrapper("imagejpeg", $img, $file);

Replace with:

// WCM - Specify jpeg quality
#return func_gd_wrapper("imagejpeg", $img, $file);
return func_gd_wrapper("imagejpeg", $img, $file, 60);
// / WCM - Specify jpeg quality

Open include/func/func.image.php

Find:

global $auto_thumb_error, $xcart_dir;

After Add:

// WCM - Force .jpg creation
$image_type = 'jpeg';
// / WCM - Force .jpg creation

Find:

$res = func_imagepng($_image, $new_file);

Replace with:

// WCM - Force .jpg creation
#$res = func_imagepng($_image, $new_file);
$res = func_imagejpeg($_image, $new_file);
// / WCM - Force .jpg creation

Find:

'image_type' => 'image/png'

Replace With:

// WCM - Force .jpg creation
#'image_type' => 'image/png'
'image_type' => 'image/jpeg'
// / WCM - Force .jpg creation

Comments on Use X-Cart .jpg thumbnails for speed and SEO



Paul Windas Mar 31, 2011
Fantastic script change. Really appriciate this one. Cheers!
Jorge Feb 15, 2011
No dice.

Changed the files several times, cleared the templates cache directory, my browser's cache and it didn't work.

I'm on 4.2... doubt anyone will reply to this though.
Paul Wallace Jun 30, 2010
Well all I get is a nasty error on customer and admin sides.
I m on 4.3.1
Parse error: syntax error, unexpected '}' in /nfs/c06/h04/mnt/95898/domains/iartsupplies.co.uk/html/include/func/func.gd.php on line 87
T.T Jun 25, 2010
Anyone else succeeded to make it work on 4.3.1 Please?
T.T Jun 3, 2010
Any idea how to do this on 4.31 would be great!
Shawn Gowans May 29, 2010
I just double checked all changes and it is still producing png files, I'm on 4.3 also :-)
Mike Kennedy May 18, 2010
I have followed the steps above to the letter in 4.3.
I have even gone into the product, deleted the thumbnail and regenerated it. It still produces a png file. Any ideas?
Shawn Gowans May 1, 2010
Wow - this is exactly what I have been trying to figure out - reduced my thumbnails from 50-80k to 4-5k after changing the quality variable to 50. Thanks so much!!!!!!

It is still generating .pngs rather than .jpgs though. Would having smarty templates set not to compile make a difference? I have double checked the php file changes.

I have about 800 thumbnails to regenerate, any way of automating this?

Thanks again,


Share comments

Your Name: *
Comments: *
Please Note: HTML Markup will be automatically removed.
The ability to post urls has been disabled by the site administrator.



Site Map