I think you may be confused as to how getImageURL()
works. The only time you need to pass in the height
or width
arguments, is if you pass in size='custom'
or omit the size
attribute altogether.
Also, when you use size='custom'
, the image gets cropped automatically based on the dimensions of the image that's been uploaded. So, in your case, you want a square image ... but what if the image that's been uploaded is not exactly square, maybe it's a rectangle. So, in that case, Mura starts at the very center of the image, then scales out from there to the outer most boundaries. If the image were a vertical rectangle, you can imagine then that the top and bottom parts of the rectangle won't make the cut. Conversely, if the image were a horizontal rectangle, then the left and right edges of the image won't make it into the cut.
What you really want in this case is a pre-defined image size called catimg
with a height
and width
attribute of 163px. To create this:
- Go to Site Config > Edit Site from the Admin area
- Click the Images tab
- Towards the bottom, click Add Custom Image Size
- Enter a Name (for example,
catimg
)
- Enter the Height
- Enter the Width
- Click Save (You now have a custom image size that can be used for any content items)
- Go to the Site Manager, and add/edit a content item
- If editing an existing content item that already has an image, click the crop marks to get to the Image Details screen. Otherwise, select an image to upload, and Publish.
- From the Image Details screen, scroll down to the custom image size you've created, and you can now Re-Crop your image to select your desired image region.
Now, anytime you call getImageURL(size='catimg')
, Mura will use this specific image to display.
Cheers!