Blog

Check the latest news and trends

Resize product page images in Hikashop

Written by 
Resize product page images in Hikashop

I've worked on a project where the client requested at some time to resize images on product page in Hikashop but make them different size for different categories.

Well, there isn't such a setting in Hikashop back-end yet.

Since there is no way to do resize products images from Hikashop back-end, I'm going to show you a quick method on how to do that.

Open your code editor and look for /components/com_hikashop/views/product/tmpl/ and in this folder search for the file called show_block_img.php.

Now that you've found the file, you need to create a custom template override to add the custom code to resize the images.

In order to do that, copy the file in to /templates/your_template/html/com_hikashop/product/, once the file it's copied open it for editing. Instead of your_template look for your template.

Search for line 27 and 28 in the file. This 2 lines of code should look like this:

	$height = (int)$this->config->get('product_image_y'); 
	$width = (int)$this->config->get('product_image_x');

Delete and replace this 2 lines of code with this code:

	// Custom code
	if ($this->categories[0]->category_name == 'Your Category Name') {
		$height = 250;
		$width = 450;
	} else {
		$height = (int)$this->config->get('product_image_y'); 
		$width = (int)$this->config->get('product_image_x');
	}

In the above code I needed to resize the images to a height of 250px and a width of 450px, but you can give whatever values you want for this 2 variables.

What the code does, it's making a comparison between all your categories and try's to see if it's matches 'Your category name'. Once this category it's found, it will use the 2 values that you've given to it in $width and $height. If no category is found with the name of 'Your category name', it will execute the default Hikashop code and will give images the default images size set in your Hikashop back-end.

If you have questions or suggestions please leave a comment and I'll get back to you.

Read 4066 times

Poll

What type of templates would you prefer?

Niche specific - 38.9%
Multiporpuse - 61.1%

Total votes: 18
The voting for this poll has ended on: January 1, 2020

Testimonials

  • I am a director for www.bluereliance.co.uk. Costas has helped us a few times with websites. He always does a Superb job, cant fault anything he does. I wish he lived in the UK so we could hire him full time and lock him in the office. Costas did it again, fantastic, finished off a website for us where our last developer left us stranded. We are very please with the work Costas has done for us and have already hired him for the 3rd time now. Thanks again Costas !! ;-)
    Mandeep Dalvair www.bluereliance.co.uk
    United Kingdom
  • 1
  • 2
  • 3