Forum
Image Resize in Master Template for another Template?
I'm wondering if I can have an image uploaded in a master template, then be able to have/resize multiple sizes of the same image to be used in a different template. I believe that I have read in the Docs that perch resizes images upon admin image upload. If that is the only time an image can be resized, can one use the perch tags to "make" the images, hide/suppress them, and access them later?
<perch:content type="image" id="image" label="Image" width="1600" />
<perch:content type="image" id="image" label="Image" width="800" suppress="true" />
<perch:content type="image" id="image" label="Image" width="400" suppress="true" />
^ This in the master template and be able to access all sizes in a different template?
In my particular case, I'm working with the Blog App. So the master template would be post.html.
That's right. If you want image sizes to use elsewhere set them up in the master template.
Cool. So when I would like to call on an image I would write something like this:
and that should call the 800px wide image that had previously been created?
Yes - although if you are in a blog template you need to use perch:blog tags not perch:content.
https://docs.grabaperch.com/docs/blog/template-tags/
Ah yes. However it seems that after I added the tag and uploaded a new photo, the blog post doesn't save correctly. I hit SAVE and just get a white screen. I re-opened the blog back end, when to edit the post and no image is saved in the image field I'm working with.
I do have "development mode" on in the perch config file if that makes a difference?
Well I got the blog to save alright when the image resize is suppressed in the post.html template. However the image resize call doesn't seem to work.
I then tried to display a resized image in post.html. That is, just delete the suppress option. Now when I try to save a new blog, it again just gives me a white screen and does not save.
Please show us your complete template.
Okie Dokie, here is post.html
Can I see your Diagnostics Report please, you can find that under Settings.
Have you also checked your PHP error log for any PHP errors, if you are getting a white screen you have a PHP error and it would be unlikely that a template issue would cause that so I am wondering if some other problem is occurring.
Diagnostics Report
Would you happen to like the extended version?
Looking into my apache error log I don't see anything that really sticks out at me, but I don't really know how to read an error log.
This pattern repeats but unless that is just starting mamp, I don't know what it means. Also looks like I have some errors regarding a missing favicon.png file. Would that disrupt Perch?
It's your PHP Error log you need to look at. If you cause this white screen and look in the log the relevant error will be at the time the error occurred.
Ah yes, sorry.
Hmm I did try to resize an image to 400px which worked. When I tried a resize to 1600px it did not work. So it seems there is a size or memory issue? The original image is 2880px at 450KB. IS perch trying to create/save the resized image at a higher file size?
Handling large images takes quite a bit of memory - you're running out. There's not much Perch can do to prevent that, unfortunately.
Alright. I'll create another field for a smaller image. Thanks for your time!