Custom field Ajax image resize

  • Posts: 278
  • Thank you received: 14
  • Hikashop Business
3 years 10 months ago #320498

-- HikaShop version -- : 4.3

Hello
I have this code in product view

<?php 
if(!empty($this->element->autorfoto)) {
	$fieldClass = hikashop_get('class.field');
	$field = $fieldClass->getField('autorfoto', 'product');
	echo '<div class="col-sm-2 avtorphot">' . $fieldClass->show($field,$this->element->autorfoto) . '</div>';
}
if(!empty($this->element->autortext)) {
	echo '<div class="col-sm-10 avtortekst">' . $this->element->autortext . '</div>'; 
}
?>

First field is custom image, second is custom text. Image is resized to 100x100. What code to use for biger image, say 150x150?

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
3 years 10 months ago #320505

Hi,

Supposing that the type of the custom field is "ajax image", you can change the line:

echo '<div class="col-sm-2 avtorphot">' . $fieldClass->show($field,$this->element->autorfoto) . '</div>';
to:
echo '<div class="col-sm-2 avtorphot">' . str_replace(array('thumbnail_x=100','thumbnail_y=100'), array('thumbnail_x=150','thumbnail_y=150'), $fieldClass->show($field,$this->element->autorfoto)) . '</div>';

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

  • Posts: 278
  • Thank you received: 14
  • Hikashop Business
3 years 10 months ago #320563

Sorry, no change.
Cleared cache, uploaded new image...

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
3 years 10 months ago #320565

Hi,

Try like that then, as you might have SEF on:

echo '<div class="col-sm-2 avtorphot">' . str_replace(array('thumbnail_x=100','thumbnail_y=100','thumbnail_x-100','thumbnail_y-100'), array('thumbnail_x=150','thumbnail_y=150','thumbnail_x-150','thumbnail_y-150'), $fieldClass->show($field,$this->element->autorfoto)) . '</div>';

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

  • Posts: 278
  • Thank you received: 14
  • Hikashop Business
3 years 8 months ago #322821

Sory still no change.
With inspector I see html

<img class="" src="/zc/order/download/field_table-product/field_namekey-YXV0b3Jmb3Rv/name-a2V6ZWxlLmpwZWc=/thumbnail_x-190/thumbnail_y-190" alt="keze.jpeg">
But image is 100px.

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
3 years 8 months ago #322826

Hi,

Then it means that the image itself is smaller than 190*190. The system will only resize down the uploaded image if it is bigger than the size specified in the parameters of the URL. OR, the image is actually resized to 190*190 and you have CSS on that area which has the browser resize the image to 100*100 dynamically when displaying the image.
I can't say for sure without looking at the page itself and checking myself with the inspector of my browser.

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

  • Posts: 278
  • Thank you received: 14
  • Hikashop Business
3 years 8 months ago #322831

I uploaded 600px image. So must be some resize problem.

Last edit: 3 years 8 months ago by mojweb. Reason: link removal

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
3 years 8 months ago #322859

Hi,

Thanks for the link. I think I've found the problem.
The thumbnail size parameters in the URL of custom ajax image fields where not properly taken into account.
Please download again the install package of HikaShop on our website and install it on yours and it will add a patch which should make it work properly.

The following user(s) said Thank You: mojweb

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

  • Posts: 278
  • Thank you received: 14
  • Hikashop Business
3 years 8 months ago #323110

Now is ok.
Thank you

The following user(s) said Thank You: Philip

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

Time to create page: 0.070 seconds
Powered by Kunena Forum