- Posts: 142
COMMUNITY FORUM
Fixed height for images
- theant
- 
				Topic Author 
- Offline
- Premium Member
		Less
		More
		
			
	
		
			
	
						12 years 9 months ago				#108691
		by theant
	
	
		
			
	
	
			
			 		
													
	
				Fixed height for images was created by theant			
			
				Hello
I need to set a fixed height for K2 images instead of the width. Is it possibile?
As you can see into the attached screenshot it should be better a fixed height than the width.
How to?
					I need to set a fixed height for K2 images instead of the width. Is it possibile?
As you can see into the attached screenshot it should be better a fixed height than the width.
How to?
Please Log in or Create an account to join the conversation.
- Matt
- 
				
- Offline
- Senior Member
		Less
		More
		
			
	
		- Posts: 56
			
	
						12 years 9 months ago				#108692
		by Matt
	
	
		
			
	
			
			 		
													
	
				Replied by Matt on topic Re: Fixed height for images			
			
				It's possible with a core edit. I will explain it how you can do it with images on category pages (catItemImage).
First find components/com_k2/templates/default/category_item.php and copy it in templates/yourTemplate/html/com_k2/templates/default. This is called a template override. With this you can update K2 without losing your core edits.
Then open category_item.php and find
There you can see this line:
Change it to:
From now on, if you set a fixed width for your category images in your ACP, you will instead set a fixed height and a dynamic width.
You need to make these steps also in the item.php (for article images). I think you can figure it out yourself now.
					First find components/com_k2/templates/default/category_item.php and copy it in templates/yourTemplate/html/com_k2/templates/default. This is called a template override. With this you can update K2 without losing your core edits.
Then open category_item.php and find
<span class="catItemImage">
		    <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
		    	<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;" />
		    </a>
		  </span>There you can see this line:
style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;Change it to:
style="height:<?php echo $this->item->imageWidth; ?>px; width:auto;From now on, if you set a fixed width for your category images in your ACP, you will instead set a fixed height and a dynamic width.
You need to make these steps also in the item.php (for article images). I think you can figure it out yourself now.
Please Log in or Create an account to join the conversation.
- theant
- 
				Topic Author 
- Offline
- Premium Member
		Less
		More
		
			
	
		- Posts: 142
			
	
						12 years 9 months ago		 -  12 years 9 months ago		#108693
		by theant
	
	
		
			
	
			
			 		
													
	
				Replied by theant on topic Re: Fixed height for images			
			
				Thanks Matt
It works!
					It works!
Please Log in or Create an account to join the conversation.
