Problem/Motivation
As of hook_image_effect_info() now has optional dimensions keys for hook_image_effect_info()
the new callback "dimensions callback" was introduced.
Idea is to provide the ability to get the image dimensions, to set the <img> width / height attributes, without additional I/O (#1129642: Populate HTML image tags with dimension attributes (like D6 imagefield) without re-introducing I/O).
Unfortunately this doesn't work for all kinds of effects since for some of them need to know the original image size first.
Example:
An effect rescales and crops the image, while keeping the aspect ratio, to have the dimensions within (not exactly fit!) a limit. This effect could lead to a situation where an image dimension is smaller than the actual limit.
In such a case there's no way to return the effect dimensions without knowing the original image.
Proposed resolution
Add a third (optional?) parameter to image_style_transform_dimensions()
- the new parameter contains the path to the transformed image.image_style_transform_dimensions()
will try to get the dimensions by calling the "dimensions callback" first but if this fails and the image path is available it will fall-back to getimagesize()
.
With this approach we can reduce the I/O to a minimum while not loosing any flexibility.
And if the new parameter is optional there won't be any behavioural changes for function calls without the parameter.
Remaining tasks
- Decide if this is an appropriate approach.
- Create patch.
- Review patch.
User interface changes
none.
API changes
A new parameter for image_style_transform_dimensions()
.
This would make changes in theme_image_style()
necessary too.