Troubleshooting and FAQ¶
The field is empty for older images¶
Media saved before the module was installed, or before the field was added to their media type, have no value until they are saved again. Run the batch at Configuration › Media › Calculate Aspect Ratios.
The Calculate Aspect Ratios page says no media type has the field¶
The site had no media type with the machine name image when the module was installed, so the field was not added to any type. Add the existing field to the media type that holds images.
Installing fails with "unmet dependencies"¶
Versions 1.0.1 to 1.0.3 did not declare the Media dependency, so enabling the module and Media in the same command failed. Current versions depend on Media and enable it.
The value did not change after editing the image¶
The ratio is recalculated when the file is replaced, not when other fields change. An image edited outside Drupal and uploaded again as a new file is recalculated. A file changed in place on the file system is not; run the batch to pick it up.
A media item has the wrong ratio after its file was replaced in code¶
When custom code replaces an image by setting only the file, core's image field can keep the previous file's width and height. This module reads the new file when the file changes, but a later recalculation of an empty value uses the stored width and height. Run the batch, which reads every file.
FAQ¶
Does saving a media item read the image file? Only when the item is new, its file was replaced, or its Aspect Ratio field is empty. A new item uses the dimensions the image field already stores.
Can I enter the ratio by hand? Yes, if the field is on the form display. The value is kept until the file is replaced or the batch is run.
Why two decimal places? The field storage has scale 2. Two decimal places separate the common shapes; 16:9 (1.78) and 16:10 (1.60) do not collide.
Does it work with remote media such as YouTube? No. Only media types whose source field is an image or file field get a ratio.