Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Image Aspect Ratio Tagging

Security covered Under active development 16 sites

This module automatically adds the aspect ratio of an image to an "image" media field, making it easier to search for images based on their aspect ratio.

Image Aspect Ratio Tagging stores the aspect ratio of each image media item in a field, so editors and Views can find images by shape. For example, they can find wide banners, square thumbnails or portrait photos without opening each file.

The ratio is stored as width divided by height, to two decimal places. Landscape images are greater than 1, portrait images are less than 1 and a square image is exactly 1. For example, 16:9 is stored as 1.78 and 9:16 as 0.56.

Features

  • Adds an Aspect Ratio decimal field (field_aspect_ratio) to the Image media type on install, when the site has one.
  • Calculates the ratio when an image media item is created or its file is replaced, or when the field is empty. Saving an item with the same file keeps the stored value, so files on remote storage such as S3 are not downloaded again.
  • Works on any media type with an image or file source that has field_aspect_ratio. To cover another type, such as a custom photo type, add the existing field to it.
  • A batch form at Configuration › Media › Calculate Aspect Ratios (/admin/config/media/aspect_ratio/recalculate) fills in the field for every media type that has it, including images that existed before the module was installed.
  • The value is an ordinary numeric field. It can be filtered and sorted in Views, so you can build a media library filter such as "between 1.7 and 1.8" for 16:9 images, or "greater than 1" for landscape.

Requirements

  • Drupal 9, 10, 11 or 12.
  • Core Media module, which is enabled with this module.

Installation and use

  1. Install the module as usual: composer require drupal/aspect_ratio, then drush en aspect_ratio.
  2. Visit Configuration › Media › Calculate Aspect Ratios and run the batch to fill in existing images. Running it needs the Administer media permission.
  3. Add the Aspect Ratio field as a filter or sort to your media Views. To see or edit the value on the media form, enable the field at Manage form display.

Uninstalling the module deletes the Aspect Ratio field and its values.

Full documentation: project.pages.drupalcode.org/aspect_ratio.

Related modules

Drupal 9–11

Ask your assistant about Image Aspect Ratio Tagging

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • media Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Sep 2025
Latest release
6 days ago
Releases (12 mo)
2 ▼ from 3
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
1.0.4 Stable 9–11 Oct 9, 2026
1.0.3 Stable 9–11 Oct 28, 2025
1.0.2 Stable 9–11 Sep 22, 2025
1.0.1 Stable 9–11 Sep 22, 2025
1.0.0 Stable 9–11 Sep 22, 2025