Open andysh-uk opened 2 years ago
I have a working proof of concept for this on my dev site, I'll create a PR.
To illustrate this, in the Bolt Git clone website, insert the following line in public/theme/skeleton/record.twig
:
{{ dump(record.photo.value) }}
Then view the /page/this-is-a-page
page.
Underneath the heading, you will see:
My PR will allow this to be controlled via a "thumbnails" configuration within the content type definition:
pages:
name: Pages
singular_name: Page
title_format: '{heading} - {subheading}'
excerpt_format: '📦 {teaser}'
fields:
photo:
type: image
label: "Eén plaatje"
placeholder: https://source.unsplash.com/1280x768/?business,workplace/__random__
.... new config below ....
thumbnails:
size: [100,100]
cropping: crop
With my change - and the above config - in place, you'll now get:
Without the above config in place (but with my change in place), you will still get the previous behaviour of 400x400 with no cropping/fitting.
In the code below, an image field will always return a "thumbnail" property as the URL to a thumbnail sized at 400x400 with no cropping/fitting, so the thumbnail will be stretched to fit 400x400.
https://github.com/bolt/core/blob/161ca2f05e25f104b07f97e4c1451fbc4ba1a69e/src/Entity/Field/ImageField.php#L67
As this is a field-level property, I feel this could be configurable on a per-field level to allow a field on one content type to return a thumbnail that is a different size to another content type.