When uploading a product picture, color problem

  • Posts: 3
  • Thank you received: 0
10 years 5 months ago #172543

-- url of the page with the problem -- : local host
-- HikaShop version -- : HikaShop Business 2.3.2
-- Joomla version -- : Joomla 3.3.3
-- Browser(s) name and version -- : Chrome

Hello,
when i upload a picture for the product page and hikashop resize it, it fills the picture with a white "background" color.
Then the former picture becomes bigger but it is surrounded by white color.
i would like to set Hikashop, if possible, to color the contour of the resized picture in blue in stead of white.
Could you tell me if that is possible?
Thank you for your help,
Meligrafi

Please Log in or Create an account to join the conversation.

  • Posts: 26210
  • Thank you received: 4032
  • MODERATOR
10 years 5 months ago #172547

Hi,

What kind of picture are you uploading ? PNG ? GIF ?
HikaShop should resize the image and keep the transparency of the image, depending how the image has been encoded, it is possible that the PHP GD library can't handle correctly the alpha channel.
Knowing more about the image could help us (and you) to understand the problem.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
10 years 5 months ago #172911

Hi,
I am uploading JPG so no alpha channel. It seems that the script is creating a white background by default when resizing the pictures. So my question is: would it be possible to change it to a blue background? ...so i can still use the automatique resize script when uploading pictures.
Thanks for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 26210
  • Thank you received: 4032
  • MODERATOR
10 years 5 months ago #172915

Hi,

Ok I see, you're using the "force size" option.
It is possible to change the background color in the parameters for the function getThumbnail of the HikaShop image helper.
In the file "administrator/components/com_hikashop/helpers/image.php" you will find the line

$bgcolor = $this->_getBackgroundColor($thumb, @$options['background']);
which define the background color of the image while scaling it.

The variable "$options" is a parameter of the function, so in your views you can set the background color without having to edit the HikaShop core file (the image helper).

More about display customization:
www.hikashop.com/support/support/documen...ize-the-display.html

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
10 years 5 months ago #173057

Thanks, it works! New background is now set to blue :cheer:
Regards.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
5 years 10 months ago #306033

What display 'override' do I need to change and what do I need to change in that file to change this color?

Last edit: 5 years 10 months ago by webwerk.

Please Log in or Create an account to join the conversation.

  • Posts: 83478
  • Thank you received: 13504
  • MODERATOR
5 years 10 months ago #306035

Hi,

Unfortunately, you'll have to do that change for each view file where the thumbnail is displayed.
So it could lead to a lot of changes: the product listings, the product page, the emails, the cart module, the cart view in the checkout, the cart details page, without even talking about the backend.
And each time the modification will be a bit different as the variable names are not necessarily the same.
To know which view file you want to change, you can activate the "Display view files" setting of the HikaShop configuration. That way, you'll be able to easily see which view file is used where (as it also depends on how your shop is configured I can't say for sure).
Then, you can edit them via the menu Display>Views.
I'll give you an example with the main image on the product details page. It's displayed with the code:

$image_options = array('default' => true,'forcesize'=>$this->config->get('image_force_size',true),'scale'=>$this->config->get('image_scale_mode','inside'));
		$img = $this->image->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
As Jerome said you need to add the 'background' option there.
So it would look like that:
$image_options = array('background'=> "#000000", 'default' => true,'forcesize'=>$this->config->get('image_force_size',true),'scale'=>$this->config->get('image_scale_mode','inside'));
		$img = $this->image->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
where #000000 is the color code for black.

The following user(s) said Thank You: webwerk

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
5 years 10 months ago #306119

Hi Nicolas,
Isn't there an easier way to make the scaled images fit for a dark background? I suppose there are more sites that use a different background color than white on their site.

Regards,
Rachel

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
5 years 10 months ago #306120

Thanks,
This was the info I was missing. It is working as I want it to now!

Regards Rachel

Please Log in or Create an account to join the conversation.

  • Posts: 83478
  • Thank you received: 13504
  • MODERATOR
5 years 10 months ago #306125

Hi,

Having a transparent background is not an issue in most cases. HikaShop will keep the transparent background as long as the ratio of the image doesn't change.
So if you have the "force size" setting turned off, or if you have the "Image scale mode" setting set to "crop" of if you upload images with the same ratio that you configured in the thumbnails size settings, it won't have to add stripes around the tthumbnails and thus the color of the stripes won't matter as their won't be any.
Now that could still be an interesting setting to be able to define the stripes color. We'll think about that for a future improvement.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
5 years 10 months ago #306165

Hi Nicolas,

I see what you mean. There are often cases that you don't want to crop the tumbnails. So in my opinion it would be a great asset to have a background-color setting in de configuration.

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
5 years 5 months ago #311540

Hi Nicolas,

I can't find the view that I need to edit to set the background color for the images shown in the cart and checkout. When I try to look with the setting "Display view files' enabled, the image doesn't get a view assigned.

Where can I set the background color for those thumbnails?

With kind regards,
Rachel Walraven

Please Log in or Create an account to join the conversation.

  • Posts: 83478
  • Thank you received: 13504
  • MODERATOR
5 years 5 months ago #311547

Hi,

Note that there is now a setting "Stripes color" in the HikaShop configuration to define the background color of thumbnails.
So you should not need to edit view files anymore.
And regarding the cart / checkout, while there is no view file which displays just the image, there is a view which displays the whole cart. It is displayed around the cart when you have the "Display view files" option enabled, and that's the view you would want to edit.
For example, for the cart on the checkout, it's the file "show_block_cart".
In there, you can find that code which displays the product thumbnails:

<td data-title="<?php echo JText::_('CART_PRODUCT_IMAGE'); ?>" class="hikashop_cart_product_image_value">
<?php
			$image = null;
			if(!empty($product->images)) {
				$image = reset($product->images);
				$this->imageHelper->checkSize($thumbnail_x, $thumbnail_y, $image);
			}

			if($image && !$this->config->get('thumbnail')) {
				echo '<img src="'.$this->imageHelper->uploadFolder_url . $image->file_path.'" alt="' . $image->file_name . '" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle" />';
			} else {
?>
				<div class="hikashop_cart_product_image_thumb" ><?php
			$img = $this->imageHelper->getThumbnail(
				@$image->file_path,
				array(
					'width' => $thumbnail_x,
					'height' => $thumbnail_y
				),
				array(
					'default' => true,
					'forcesize' => $this->config->get('image_force_size', true),
					'scale' => $this->config->get('image_scale_mode', 'inside')
				)
			);
			if($img->success) {
				$attributes = '';
				if($img->external)
					$attributes = ' width="'.$img->req_width.'" height="'.$img->req_height.'"';
				echo '<img class="hikashop_product_checkout_cart_image" title="'.$this->escape(@$image->file_description).'" alt="'.$this->escape(@$image->file_name).'" src="'.$img->url.'"'.$attributes.'/>';
			}
				?></div>
<?php
		}
?>
			</td>

Please Log in or Create an account to join the conversation.

  • Posts: 42
  • Thank you received: 0
  • Hikashop Business
5 years 5 months ago #311587

That is such a great option to have! No need to edit the cart file!
Thank you Nicolas

With kind regards,
Rachel Walraven

Please Log in or Create an account to join the conversation.

Time to create page: 0.093 seconds
Powered by Kunena Forum
loading