Forum

Thread tagged as: Question, Problem, Error

Displaying smaller size image on Home page

Hi, I am saving my image in a couple of formats in the first template here:-

<perch:if exists="mediumimage">

       <img src="<perch:content id="mediumimage" type="image" label="medium size image" width="300" height="300" />"
          alt="<perch:content id="mediumimagealt" type="text" label="brief description of image" />" class="image8"  align="bottom"/>
          <perch:content id="mediumimage" type="image" label="home image" width="150" height="150" suppress="true" />

 </perch:if>  

Then using the medium image if it exists on my News page https://www.feelgood-factor.co.uk/newsoffersfgf.html

However, I want a brief summary of the news displayed on the Home page with a smaller version of the image if it exists and am using perch_content_custom to redisplay the smaller version of the saved image. Template code:-

  <perch:if exists="mediumimage">

       <img src="<perch:content id="mediumimage" type="image" label="medium size image" width="150" height="150" />"
          alt="<perch:content id="mediumimagealt" type="text" label="brief description of image" />" class="image8"  align="bottom"/>

 </perch:if>  

The image is being displayed but with larger dimensions rather than a smaller version of the image that I expected. Is the format of my coding correct?

Thanks Karen

Karen Blaylock

Karen Blaylock 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

When you get the larger image, is it for those where the smaller image doesn't exist?

Hmm, well I was thinking that when I initially uploaded 'mediumimage' with a set size of max 300 width and height at that point it created but did not display a smaller version of the image max width and height 150 for use elsewhere in the website - although I can't see another sized image in my asset store.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Your second image tag needs to have the exact same attributes and values as the first one, I don't think it needs suppress="true" as you will only get one field for upload as they have the same id. The only thing different about it should be the sizes.

Ok, I'll try that.

Hi,

I didn't want to show the small imageon that page so I had to put the suppress in. I have tweaked the code and it now works OK

<perch:if exists="mediumimage">

       <img src="<perch:content id="mediumimage" type="image" label="Article image" width="300" height="300" />" 
       alt="<perch:content id="mediumimagealt" type="text" label="Alt text" />"
       class="image8"  align="bottom"/>

       <perch:content id="mediumimage" type="image" label="Article image" width="150" height="150" suppress="true" /> 

</perch:if>

Thanks karen