Forum

Thread tagged as: Question, Problem, Blog

Problem getting multiple image sizes

Hey there,

I have my blog set up and use four different templates:

index-post.html -> latest article complete on home page (1920 px wide image):

<img src="<perch:blog id="image" type="image" width="1920" quality="60" />" />

index-posts.html -> excerpts of the three posts before that on the home page (960 px wide image):

<img src="<perch:blog id="image" type="image" width="960" quality="60" />" />

The top two I both added in my index.php:

<?php
perch_blog_custom(array(
'sort'=>'postDateTime',
'sort-order'=>'DESC',
'template'=>'index-post.html',
'count'=>1
)); 
?>

<?php
perch_blog_custom(array(
'paginate'=>false,
'sort'=>'postDateTime',
'sort-order'=>'DESC',
'template'=>'index-posts.html',
'start'=>2,
'count'=>3
)); 
?>

My other template are added in the same way to separate archive.php and blogpost.php files:

all-posts.html -> Archive of all posts (960 px wide image):

<img src="<perch:blog id="image" type="image" width="960" quality="60" />" />

post.html -> detail view (1920 px wide image):

<img src="<perch:blog id="image" type="image" width="1920" quality="60" />" />

The templates with the bigger 1920 px images both work fine. But the templates using the smaller 960 px images output the original 4000 x 3000 px image without any changes.

To clarify: Whenever I make changes to the code, I delete the image from the blog post, then from assets, and re-upload the image.

After reading a thread that states all needed image sizes have to be in the post.html master template, I tried adding the following code to post.html (just at the bottom of the file). I also tried adding suppress="true".

<perch:blog id="image" type="image" width="960" quality="60" />

Either way, now I get an Internal Server Error. When I remove the additional perch:blog tag shown above, it’s back to the original behavior, but no 960 px wide image.

I'd be glad to get help on this!

Cheers Jannis

Jannis Borgers

Jannis Borgers 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Yes all images need to be in your master template, that is explained in the documentation. You will not get a cropped image unless the image is there.

An "internal server error" message is an error notification. So you will need to look in your PHP error log and let us know what the actual error being thrown is.

Thanks for your reply.

I don’t know exactly why, but I managed to get most images uploaded, with working resizing, by adding the perch_content-Tag to my post.html again, suppressing output and omitting the quality setting.

One image was still giving me an an Internal Server Error (I have asked for access to the PHP error log). This was solved when I added the image in Assets first and then selected it in the Blog app. Uploading directly from the Blog app still results in an Internal Server Error.

I'll post the error log as soon as I have access to it. Thank you for your help!