Skip to main content
page last edited on 3 December 2014

Disabling on-fly image resizing

Version: 5.4 and early


Default X-Cart lazy resizes images and this article describes how to disable this process.

To illustrate the image-resizing process, imagine that you uploaded 5000px x 5000px product image and this image is used for thumbnail. Default thumbnail size is 160px x 160px and showing this huge image to a client without resizing would unnecessarily slow down the load time of the page, that is why X-Cart will resize 5000x5000 image on-fly and then store this resized copy to an image cache.

Disabling image resizing routine

In order to disable image resizing routine in a whole store you can apply the following simple mod:

  1. Create an empty module. We are creating a module with developer ID XCExample and module ID DisableImageResize.

  2. Decorate the \XLite\View\Image class (more info about classnames), so that your class would look as follows: 

    // vim: set ts=4 sw=4 sts=4 et:

    namespace XLite\Module\XCExample\DisableImageResize\View;

    * Image
    class Image extends \XLite\View\Image implements \XLite\Base\IDecorator
    protected function defineWidgetParams()

    $this->widgetParams[self::PARAM_USE_CACHE] = new \XLite\Model\WidgetParam\TypeBool('Use cache', 0);
  3. The only thing we change is we set PARAM_USE_CACHE to false. If you check default \XLite\View\Image class, you will see that this PARAM_USE_CACHE triggers this condition: 

    $url = $this->getParam(self::PARAM_USE_CACHE)
    ? $this->resizedURL
    : $this->getParam(self::PARAM_IMAGE)->getFrontURL();

    so if PARAM_USE_CACHE is true, then X-Cart returns a resized image, otherwise it returns default image URL.

  4. Now it is time to re-deploy the store and check the results in store-front.

Module pack

You can download this module example here: XCExample-DisableImageResize-v5_3_0.tar