Remove the image resize ratio in OpenCart

后端 未结 1 1045
独厮守ぢ
独厮守ぢ 2021-02-10 02:11

I\'ve look everywhere on how I could remove the image resizing in OpenCart but haven\'t find nothing about that.

I need that it resize but don\'t keep the ratio. I want

相关标签:
1条回答
  • 2021-02-10 02:58

    First of all I would leave the default resizing tool as in some circumstances it might come in handy. What I did was add two more functions to resize images.

    One function that crops an image so it fits the size set in the admin. Now empty white areas are added. This one is great for product lists. The second I added is a function that resizes an image so the biggest dimension will be set to the max size set in the admin. It will be scaled proportionally.

    The new files are posted in an OpenCart forum thread.

    I named the two extra functions cropsize and onesize. All you have to do is find the used resize functions in the controller and adjust this:

    'thumb' => $this->model_tool_image
                    ->resize($image, 
                             $this->config->get('config_image_category_width'), 
                             $this->config->get('config_image_category_height')));
    

    to:

    'thumb' => $this->model_tool_image
                    ->cropsize($image, 
                               $this->config->get('config_image_category_width'), 
                               $this->config->get('config_image_category_height')));
    

    The onesize function only needs one parameter so it's up to you but you could use something like this:

    'popup' => $this->model_tool_image
                    ->onesize($result['image'], 
                              $this->config->get('config_image_popup_width'))
    

    I hope this will help you getting better images.

    0 讨论(0)
提交回复
热议问题