Forum

Thread tagged as: Question

version 2 perch blog templates

Using latest version 2 perch and latest blog

which default templates are used to display posts on blog/index.php and blog/post.php ? I only ask as images for same post display at different sizes on those two pages

Charlie Elsey

Charlie Elsey 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug, you can see all the templates being used.

Thanks Drew... both using same post.html template, which is what I would have thought

so in post.html I have

<img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image 1" order="4" />" class="scalable" alt="<perch:blog id="postTitle" />" />

But the differing output html is as follows, so one is using unsized uploaded images, the other is using the correctly resized version

<img src="/perch/resources/hdc-royal-ascot.jpg" class="scalable" alt="HdC at Royal Ascot" />

<img src="/perch/resources/hdc-royal-ascot-w320h240.jpg" class="scalable" alt="HdC at Royal Ascot" />

Please can you post the full post.html template you are using. Thanks.

It's possible to set two or more image sizes in the post.html template. One image would be for use on the blog/post.php page and the other as a thumbnail on the blog post listing page, blog/index.php

However, in most cases, this means that you would be using different templates for each page. In your case, it seems not but if you post the full template, this will show what image sizes are being set (or not).

<article class="h-entry"> <h1> <a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name"> <perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /> </a> </h1> <p class="meta"> <time class="dt-published" datetime="<perch:blog id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Publishing" />"> <perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" /> </time> <perch:if exists="authorGivenName"> by <span class="p-author h-card"><perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /></span> </perch:if>
<perch:categories id="categories" set="blog" label="Categories" display-as="checkboxes"> <a href="archive.php?cat=<perch:category id="catSlug" type="slug" />" class="p-category"> <perch:category id="catTitle" type="text" /> </a> </perch:categories>

</p>
<perch:if exists="image">
    <div><p>
        <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image 1" order="4" />" class="scalable" alt="<perch:blog id="postTitle" />" /></p>
    </div>
</perch:if>
    <perch:if exists="image2">
    <div><p>
        <img src="<perch:blog id="image2" type="image" width="320" height="240" crop="true" label="Image 2" order="5" />" class="scalable" alt="<perch:blog id="postTitle" />" /></p>
    </div>
</perch:if>
<div class="description e-content">
    <perch:blog id="postDescHTML" type="textarea" label="Post" order="2"  editor="redactor" html="true"  size="xxl autowidth" required="true" />
</div>

</article>

<perch:blog id="excerpt" type="textarea" label="Excerpt" editor="redactor" html="true" order="3" suppress="true" size="s" /> <perch:blog id="image" type="image" width="50" height="50" crop="true" suppress="true" /> <perch:blog id="image2" type="image" width="50" height="50" crop="true" suppress="true" />

It looks like you are using two images, id="image" and id="image 2" in your template. Each of these is generated in 320 x 240 px and 50 x 50 px sizes. So, if you use the appropriate image as its smaller size in a separate template on the blog/index.php page (I assume), that should display the smaller image.

(You may have a post_in_list.html template that you can use on the blog/index.php page)

SORTED re-upload of images and endless republishing has got it to work

Thanks. The issue is that while both pages should be using the same template (and on neither am I specifying anything different) the output is not the same and on blog/index page the images are displayed as uploaded, i.e. not resized at all as they should be. Seems weird. In blog admin they are correctly showed as being at the 320 x 240