Keyword

Category Item image change size

  • Nuno Costa
  • Nuno Costa's Avatar Topic Author
  • Offline
  • New Member
More
10 years 10 months ago - 10 years 10 months ago #120450 by Nuno Costa
Replied by Nuno Costa on topic Re: Category Item image change size

Try with width:auto !important;


It worked, but did not solve my problem problem completely.

The image took over the default size but still will not let me change the size.

More precisely, if I change the image size using the category default sizes large, medium, small, and so on, the image takes on the dimensions that are defined in the default parameters... but if I change the dimensions in categories parameters, the new dimensions are not recognized keeping the originals.

Another thing, when I changed to "width: auto !important" the image was centered, but applying "float: left" was fixed.

PS: I also tried using the "inherit !important" but the result was the same.

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #120451 by Yiota
Replied by Yiota on topic Re: Category Item image change size
OK. The image once uploaded is being resized into 5 sizes according to the K2 Parameter sizes. Which means that if you are loading the Medium size and the image has size 400px when you put a different size through the category parameters the image size doesn't change. In fact the new width size is just added through a style="width: category_image_width" in your case 100px;
In order for this size to override all others you need to edit the category_item.php file of your template overrides and locate this code
<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
and change it to this code
<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px !important; height:auto;" />

This will tell your image to always be sized according to the size you provide through the category parameters.

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

  • Nuno Costa
  • Nuno Costa's Avatar Topic Author
  • Offline
  • New Member
More
10 years 10 months ago #120452 by Nuno Costa
Replied by Nuno Costa on topic Re: Category Item image change size
This correction in addition to having solved the problem also allowed me to dispense override it had done previously.

I also noticed that this problem with the image default sizes also happened with the item ... I did the same correction in the item.php file and also solved the problem.

thank you! :)

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #120453 by Yiota
Replied by Yiota on topic Re: Category Item image change size
You are welcome.

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


Powered by Kunena Forum