Forum
Image cropping
My images aren't cropping.
I have set my image size in image.html and in post.html (see below)
I dont have gd or image magic installed - but I thought it would crop down without it?
Is there somewhere else it should be set?
I'm uploading the images in blog posting and they are coming in at 1110x800 etc so definitely not cropping.
NB I have tried following the video : Upload, crop and resize. The Perch documentation folder Template/Template Tag Attributes doesnt seem to contain Image(image upload attributes) any more?
post.html : <perch:if exists="image"> <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Main Image" suppress="true"/>" alt="<perch:blog id="postTitle" suppress="true"/>" />
image.html <img src="<perch:content type="image" id="image" label="Image" width="320" height="240" crop="true" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="e.g. Photo of MD John Smith with his best wig on" title="true" />" />
You need either GD or ImageMagick to do any cropping or other processing of images.
Where do I install those. On my server? Does Perch need them in a specific place?
They are part of the PHP install, so you would need to ask your host.
Thanks - does it matter which one I use - and if I get one added do I need to tell Perch which one I have used, or will it just know?
You don't need to tell Perch anything, and no it doesn't matter. Once it is installed you will be able to see by loading your Diagnostics Report that it is available.
If you need any further help remember we need your Diagnostics Report with every post to the forum.
I checked with my hosting co and GD is installed (I then checked my diagnostics report which shows it too).
What should I do to make the image crop work? Is it image.php or post.php I should be adding the crop sizes to? I thought it used to be image.php but this is in the content not blog section so I guess it must be the post.php. The code I have in post.php is :
You've got a mixture of
perch:content
andperch:blog
tags in your template. Which app is this template for? They should all be one or the other.Ah yes - I was trying every permutation. Its a blog thing - I just tried content in there because of the image.html which seems to only be for content? Anyway, I've put it all back to blog now.
Its still not resizing the first image (but the second is ok). I can probably get round it by renaming image - but where is image getting set? Is it in image.html? or in post.php?
Thanks
post.html is the Master template.
It needs to contain all versions of the image you want, in each size. You can then reuse them in other templates.
This is my post.html (I mistyped it as post.php). It's huge because there are so many images!! The first Image is defined in here (as 320x240 - it's near the top) but the first image isn't getting cropped. I assumed image was also set somewhere else.
What I would do in that situation is to debug the issue by removing all of the images except one, checking that works and then adding things back in one at a time until you discover which element causes the issue.
You need to take a step by step methodical approach to finding where the issue is, as the likely issue is a problem with your template.
There is a good article here on creating a reduced test case https://css-tricks.com/reduced-test-cases/
This is essentially what you need to do when something isn't working correctly whether it is front-end code or a Perch template.
Thanks I will try that
Turned out I needed to refer to the cropped size wherever I refered to the image (I thought it cropped it when the resource was added and was then always the cropped size)
ie <img src="<perch:blog id="image10" type="image" width="780" height="490" crop="true" />" />
rather than <img src="<perch:blog id="image10" type="image" class="img-responsive" />" />
Yes, that's correct.