Keyword

Set up the width and height

  • Nickos Dandoulakis
  • Nickos Dandoulakis's Avatar Topic Author
  • Offline
  • New Member
More
6 years 3 weeks ago #168918 by Nickos Dandoulakis
Set up the width and height was created by Nickos Dandoulakis
I want to setup specific dismensions of category listing item image ... For example every item in category list i want to have 400px width and 200px height ... I dont know which code in k2.css must change. Sorry about my english.

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

More
6 years 3 weeks ago #168921 by JoomlaWorks
Replied by JoomlaWorks on topic Set up the width and height
First you need to setup the width of all the sizes that an image is resized to when uploaded in K2. You can do this globally (K2 parameters) or even per category (category parameters). Make sure one of these sizes (e.g. M for Medium size) is 400px wide. This will restrain your images horizontally to 400px. Provided your users won't upload portrait images (tall), you can enforce the height of 200px using some CSS. E.g.
.catItemImageBlock a {display:block;width:400px;height:200px;overflow:hidden;}
.catItemImageBlock a img {display:block;}

Alternatively, change the template by creating an override inside your Joomla template (read this getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates) and then place the image of the item as background image in the image container and use background-size:cover to make the image stretch to fill your 400x200 px container. More on that here: developer.mozilla.org/en-US/docs/Web/CSS/background-size

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum