• WEBSITECM IS NOW
    Smack Digital Inc.

How To Use X-Cart .jpg Thumbnails For Speed And SEO

Posted by and last updated Feb 10, 2014 05:46 PM

Improve the speed of your X-Cart by using JPG thumbnails instead of the default PNG 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.

X-Cart Thumbnail Admin Example


X-Cart 4.4

These X-Cart versions have an admin option under "Settings -> General Settings -> Appearance."
Select the JPEG option as follows:

X-Cart Thumbnail Image Type Setting


X-Cart 4.2-4.3

Since no configuration is available in these X-Cart versions, you can change the thumbnail generation with the following code changes.

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

About the Author

Jonathan Peters Jonathan's founder of Smack Digital, a digital strategy agency that creates and executes online business success for executives who are highly motivated to quickly increase their market share. With more than two decades of experience on the web for clients ranging from non-profits to billion dollar enterprises, Jonathan's an expert in web development, eCommerce, software programming, search engine optimization and social media marketing.

Browse By Category

RSS Feeds

Don't miss out! Subscribe to our RSS Feeds to receive instant notification when new entries are added.

RSS Feed for All Categories
RSS Feed for X-Cart How-Tos
We choose our clients selectively.
Let's talk success. Apply to work with us.
Apply toWork With Us
Apply toWork With Us