X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Thumbnail size in xc5 (https://forum.x-cart.com/showthread.php?t=69263)

RichieRich 05-29-2014 05:31 AM

Thumbnail size in xc5
 
Is there a setting for the thumbnail size? As the thumbnail images are generated I would like to make mine slightly larger, maybe 180px or 200px.

tony_sologubov 06-02-2014 03:48 AM

Re: Thumbnail size in xc5
 
Hi Richard!

These values are hard-coded. However, you can easily define new values by creating a decoration of the XLite/View/ProductBox class in your module.

You should override the following method in this class:
PHP Code:

protected function defineWidgetParams()
    {
        
parent::defineWidgetParams();

        
$this->widgetParams += array(
            
self::PARAM_PRODUCT_ID => new \XLite\Model\WidgetParam\ObjectId\Product('Product Id'0true),
            
self::PARAM_ICON_MAX_WIDTH => new \XLite\Model\WidgetParam\Int(
                
'Maximal icon width'160true
            
),
            
self::PARAM_ICON_MAX_HEIGHT => new \XLite\Model\WidgetParam\Int(
                
'Maximal icon height'160true
            
),
        );
    } 


Quote:

Originally Posted by RichieRich
Is there a setting for the thumbnail size? As the thumbnail images are generated I would like to make mine slightly larger, maybe 180px or 200px.


RichieRich 06-03-2014 08:00 AM

Re: Thumbnail size in xc5
 
Is this likely to become a standard setting do you think? It is in x-cart 4. Also, is there any reason the image quality is reduced in the thumbnail generation so much? I understand the performance/ load time of higher image, but what if you only had 5 high-end products. It appears about 70% reduction in quality for thumbnails.

Also, there could be 2 thumbnails generated, with one displayed to standard screen and one to retina display screens.

tony_sologubov 06-03-2014 02:00 PM

Re: Thumbnail size in xc5
 
We are thinking of it, but not sure yet.

Generally the size of thumbnail is dictated by the theme, so the size of thumbnails is the option of a theme, not the entire store. X-Cart 4 has such settings, but most of 3rd party skins disregard them.

As for thumbnail quality, there are two sides of the coin, some merchants want lower quality, small images, some want high quality and do not care about size. That is why we implemented it in a way to cover the general majority of users (as we felt) and now are getting feedback about what is good and what can be improved. At this point, you can easily apply the mod, so your thumbnails would not be that much resized + you can register an idea about high quality thumbnails.

As for retina images, I believe, it should implemented as a mod and X-Cart allows to define you two images for a single thumbnail in order to server retina needs.

Quote:

Originally Posted by RichieRich
Is this likely to become a standard setting do you think? It is in x-cart 4. Also, is there any reason the image quality is reduced in the thumbnail generation so much? I understand the performance/ load time of higher image, but what if you only had 5 high-end products. It appears about 70% reduction in quality for thumbnails.

Also, there could be 2 thumbnails generated, with one displayed to standard screen and one to retina display screens.


RichieRich 06-03-2014 04:54 PM

Re: Thumbnail size in xc5
 
Quote:

Originally Posted by tony_sologubov
We are thinking of it, but not sure yet.

Generally the size of thumbnail is dictated by the theme, so the size of thumbnails is the option of a theme, not the entire store. X-Cart 4 has such settings, but most of 3rd party skins disregard them.



I think there is space for a larger thumbnail without breaking the theme. And it could be allowed up to a maximum of the space that is allowed, or even if you have a bigger thumbnail, it will squeeze into the size of the theme in this new repsonsive templates which dont allow images to go outside the containers.

tony_sologubov 06-04-2014 03:32 AM

Re: Thumbnail size in xc5
 
That is true if we are talking about default theme. But most of 3rd party themes just force the exact thumbnail size. They do not want to support several thumbnail sizes.

So, there will be a setting an admin area and merchants would think that it affects the display, but if they install 3rd party theme, this setting suddenly stops working. We do not want this effect.

Quote:

Originally Posted by RichieRich
I think there is space for a larger thumbnail without breaking the theme. And it could be allowed up to a maximum of the space that is allowed, or even if you have a bigger thumbnail, it will squeeze into the size of the theme in this new repsonsive templates which dont allow images to go outside the containers.


RichieRich 06-04-2014 03:45 AM

Re: Thumbnail size in xc5
 
Dont most people use default responsive theme? Is there a way you can make a setting if the customer is using the default responsive theme for the majority?

tony_sologubov 06-25-2014 01:41 PM

Re: Thumbnail size in xc5
 
Hi Richard!

Sorry for being silent for a while. We have been to IRCE. Now I am back from the trip and catching up with all the work.

I am not sure, but I feel that majority of people tend to use a custom theme. Anyways, if you feel that this setting is a must, please post an idea here:
http://ideas.x-cart.com/forums/229428-x-cart-5-ideas

We want to implement features that are needed for merchants/developers, so your voice would be highly appreciated.

Finally, if you need to change the thumbnail sizes in your own store, I can show you the approach as a part of dev docs. Now I am working on complete guide for theme creation, so I will describe this process there.

UPDATE: oops, I already explained it earlier in this thread: http://forum.x-cart.com/showpost.php?p=373839&postcount=2

Tony.

spdesign 10-31-2014 02:49 PM

Re: Thumbnail size in xc5
 
I have been trying to change the size of the category icons. Am I correct that the procedure is to create

/XLite/modules/MyName/MyThemeName/View/Subcategories.php

which has the code

Code:

namespace XLite\Module\MyName\MyThemeName\View;

class Subcategories extends \XLite\View\Subcategories implements \XLite\Base\IDecorator
{
 
    protected function defineWidgetParams()
    {
        parent::defineWidgetParams();

        $this->widgetParams += array(
            self::PARAM_DISPLAY_MODE => new \XLite\Model\WidgetParam\Set(
                'Display mode', $this->getDisplayMode(), true, $this->displayModes
            ),
            self::PARAM_ICON_MAX_WIDTH => new \XLite\Model\WidgetParam\Int(
                'Maximal icon width', 200, true
            ),
            self::PARAM_ICON_MAX_HEIGHT => new \XLite\Model\WidgetParam\Int(
                'Maximal icon height', 200, true
            ),
        );
    }

}


to change icon size to 200px? It doesn't seem to work for me. Icons remain at 160px.

tony_sologubov 11-03-2014 04:03 AM

Re: Thumbnail size in xc5
 
It should've worked out. Could you please send your whole module, so I could check?

Tony.

DTS 12-02-2014 03:10 PM

Re: Thumbnail size in xc5
 
Is there a way to disable the resizing of the icons so we can control our layout without software intervention?

totaltec 12-02-2014 03:39 PM

Re: Thumbnail size in xc5
 
Quote:

Originally Posted by DTS
Is there a way to disable the resizing of the icons so we can control our layout without software intervention?

I think it may be more trouble than it is worth. Looks like the resize function is triggered in XLite\Model\Base\Image. The method I'm looking at is resizeIcon

That would be a starting point, but I see so much code that depends upon this that I think it would be a massive undertaking to disable it completely. Much easier to simply embrace it and twist it to your own advantage.

tony_sologubov 12-03-2014 02:46 AM

Re: Thumbnail size in xc5
 
Guys, I just wrote an article about disabling resizing routine here:
http://kb.x-cart.com/display/XDD/Working+with+image+resizing+routine

Check it out!

totaltec 12-03-2014 03:30 AM

Re: Thumbnail size in xc5
 
Very cool Tony! Your mod is an elegant way to handle this.

flipp2k 02-23-2015 09:21 AM

Re: Thumbnail size in xc5
 
Hi Tony,

I'm also having trouble with resizing thumbnail images. I tried the solution you suggested but it also isn't working for me. Any Ideas?

tony_sologubov 02-24-2015 04:47 AM

Re: Thumbnail size in xc5
 
Hello @flipp2k and welcome to X-Cart community.

Could you please give me more details about what you were trying to achieve, what you did and what actually happened instead of what you expected to see?

ant99 03-05-2015 10:46 AM

Re: Thumbnail size in xc5
 
Everything here seems really useful and exactly fitting for what I need. I am wanting to change the category thumbnail size to 300x300. I'm also wanting to change the product thumbnail size to 300x300. As of now, the categories are showing 160x160. Also the products in the grid view are showing 160x160.

However, I tried integrating this into my theme and it doesn't seem to be working at all? What am I missing? Attached are the files that I've added to my module. Any insight is appreciated!

/XLite/Module/DevID/ModuleID/View/ProductBox.php
PHP Code:

<?php
namespace XLite\Module\DevID\ModuleID\View;

abstract class 
ProductBox extends \XLite\View\ProductBox implements \XLite\Base\IDecorator

{   

    protected function 
defineWidgetParams() 
        { 
            
parent::defineWidgetParams(); 

            
$this->widgetParams += array( 
                
self::PARAM_PRODUCT_ID => new \XLite\Model\WidgetParam\ObjectId\Product('Product Id'0true), 
                
self::PARAM_ICON_MAX_WIDTH => new \XLite\Model\WidgetParam\Int
                    
'Maximal icon width'300true 
                
), 
                
self::PARAM_ICON_MAX_HEIGHT => new \XLite\Model\WidgetParam\Int
                    
'Maximal icon height'300true 
                
), 
            ); 
        }

}
?>


/XLite/Module/DevID/ModuleID/View/Subcategories.php
PHP Code:

<?php
namespace XLite\Module\DevID\ModuleID\View;

class 
Subcategories extends \XLite\View\Subcategories implements \XLite\Base\IDecorator
{
   
    protected function 
defineWidgetParams()
    {
        
parent::defineWidgetParams();

        
$this->widgetParams += array(
            
self::PARAM_DISPLAY_MODE => new \XLite\Model\WidgetParam\Set(
                
'Display mode'$this->getDisplayMode(), true$this->displayModes
            
),
            
self::PARAM_ICON_MAX_WIDTH => new \XLite\Model\WidgetParam\Int(
                
'Maximal icon width'300true
            
),
            
self::PARAM_ICON_MAX_HEIGHT => new \XLite\Model\WidgetParam\Int(
                
'Maximal icon height'300true
            
),
        );
    }

}
?>


tony_sologubov 03-10-2015 12:08 PM

Re: Thumbnail size in xc5
 
@ant99 it should have worked out. Could you please send me your module, so I could check out what is wrong exactly?

Tony.

tony_sologubov 03-17-2015 11:42 AM

Re: Thumbnail size in xc5
 
Thanks for sending me the module.

The correct implementation of the \XLite\Module\Dev-ID\Module-ID\View\Subcategories class should be as follows:

PHP Code:

<?php

namespace XLite\Module\Dev-ID\Module-ID\View;

abstract class 
Subcategories extends \XLite\View\Subcategories implements \XLite\Base\IDecorator
{
    public function 
setWidgetParams(array $params)
    {
        
parent::setWidgetParams($params);

        
$this->widgetParams[static::PARAM_ICON_MAX_WIDTH]->setValue(300);
        
$this->widgetParams[static::PARAM_ICON_MAX_HEIGHT]->setValue(300);
    }
}


In other words, you should decorate the setWidgetParams() method instead of defineWidgetParams() one.

ant99 03-26-2015 10:27 PM

Re: Thumbnail size in xc5
 
Quote:

Originally Posted by tony_sologubov
In other words, you should decorate the setWidgetParams() method instead of defineWidgetParams() one.


Thank you, that works perfectly for the Category images. However, I tried to apply the fix for Product thumbnail images also and had no success. Here is what I have.

PHP Code:

<?php
namespace XLite\Module\Dev-ID\Module-ID\View;

abstract class 
ProductBox extends \XLite\View\ProductBox implements \XLite\Base\IDecorator

{   

    public function 
setWidgetParams(array $params)
        { 
            
parent::setWidgetParams($params); 

            
$this->widgetParams[static::PARAM_ICON_MAX_WIDTH]->setValue(300);
            
$this->widgetParams[static::PARAM_ICON_MAX_HEIGHT]->setValue(300);
        }

}

?>


Any suggestions? Thanks for your help.

tony_sologubov 04-02-2015 05:55 AM

Re: Thumbnail size in xc5
 
Hello,

You need to extend the \XLite\View\ItemsList\Product\Customer\ACustomer class instead of \XLite\View\ProductBox one. Please, let me know if it works out for you.

Tony

flipp2k 04-02-2015 08:47 AM

Re: Thumbnail size in xc5
 
Thanks for the response Tony. As a temporary fix I went ahead and disabled the image re-sizing from the image.tpl template file.

Tomek 05-04-2015 09:07 PM

Re: Thumbnail size in xc5
 
Hi Tony,

Thanks for the instructions. I have followed them and made the changes.

It didn't work and found that some of the directory listings are not the same for the version I'm using.

Ver. 5.2.4 (recently updated)

All I want to do is enlarge the "product_thumbnail" in the subcategories.php?

(I hope these are the right terminology)

Any tips, guidance would be appreciated as there is not much info on the latest version.

Cheers, Tom


Quote:

Originally Posted by tony_sologubov
Thanks for sending me the module.

The correct implementation of the \XLite\Module\Dev-ID\Module-ID\View\Subcategories class should be as follows:

PHP Code:

<?php

namespace XLite\Module\Dev-ID\Module-ID\View;

abstract class 
Subcategories extends \XLite\View\Subcategories implements \XLite\Base\IDecorator
{
    public function 
setWidgetParams(array $params)
    {
        
parent::setWidgetParams($params);

        
$this->widgetParams[static::PARAM_ICON_MAX_WIDTH]->setValue(300);
        
$this->widgetParams[static::PARAM_ICON_MAX_HEIGHT]->setValue(300);
    }
}


In other words, you should decorate the setWidgetParams() method instead of defineWidgetParams() one.


tony_sologubov 05-05-2015 02:36 AM

Re: Thumbnail size in xc5
 
Hello @Tomek,

Could you please send me the module you wrote? I will try to point the problem.

Tony

Tomek 05-05-2015 05:14 PM

Re: Thumbnail size in xc5
 
Thanks Tony for your quick response.
I have not written a module.
All I did, was edit the source files (of course made backups and restored back to original afterwards)
Fairly new to this, so might not understand all the jargon and how to's.

Tom

totaltec 05-05-2015 05:18 PM

Re: Thumbnail size in xc5
 
Tomek,
I have a simple tutorial that may help you tremendously: https://www.youtube.com/watch?v=jGmeHJKP_c8

You do not edit anything in the core files. You always create a module for use in your store.

Tony also has a webinar recording about creating a module: https://www.youtube.com/watch?v=mOzC7mknjwQ

And this KB article: http://kb.x-cart.com/display/XDD/Step+1+-+creating+simplest+module

You may also find X-Cart 5 SDK useful: http://kb.x-cart.com/display/XDD/X-Cart+SDK

Tomek 05-06-2015 04:58 AM

Re: Thumbnail size in xc5
 
Thanks Totaltec for all the information.

The first video definitely explains what needs to be done. So easy to understand!

Will need to go through a learning curve now and will let you now later how I go.

In the meantime, if there are any more simple tutorials, please post them,

Cheers, Tomek.

Tomek 05-19-2015 03:45 AM

Re: Thumbnail size in xc5
 
Thank you Tony and totaltec for your help in this forum.

Once I understood about custom templates, the rest was fairly simple.

Cheers!


All times are GMT -8. The time now is 03:43 PM.

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