Installation¶
Requirements¶
- Drupal 9, 10, 11 or 12.
- The core Media module. It is a dependency and is enabled with this module.
Install¶
Or enable Image Aspect Ratio Tagging at Extend.
What installing adds¶
- The field storage
media.field_aspect_ratio: a decimal with precision 10 and scale 2, so the ratio is stored to two decimal places. - The Aspect Ratio field on the media type with the machine name
image, if the site has one. This instance is optional configuration, so the module also installs on sites without that media type. On those sites, add the field to the media type that holds images. - The Calculate Aspect Ratios page at Configuration › Media (
/admin/config/media/aspect_ratio/recalculate).
The field is not added to any form or display. See Configuration to show it.
Fill in existing images¶
Media saved before the module was installed have an empty field. Run the batch at Configuration › Media › Calculate Aspect Ratios. See Usage.
Uninstall¶
Uninstalling the module deletes the Aspect Ratio field from every media type and deletes its values. Drupal lists the field on the uninstall confirmation page. Views that filter or sort by the field lose that filter or sort.