spicywebau / craft-embedded-assets

Manage YouTube videos, Instagram photos, Twitter posts and more as first class assets in Craft CMS
MIT License
171 stars 34 forks source link

Aspect ratio is in an unexpected form #247

Closed tremby closed 6 months ago

tremby commented 6 months ago

Bug Description

I'm seeing aspect ratio come back is 56.25 for 16:9 content, which suggests it's calculated by taking the height as a percentage of the width. But aspect ratio is the ratio of width to height, not height to width. I'd expect it to be given either as an exact fraction like "16/9" or "16:9" or [16, 9], or as a decimal number like 1.777778.

I realize changing it would be breaking, but I know most developers will be surprised to see it come back as 100 * height / width, so maybe it's something to consider for a future major release.

Steps to reproduce

  1. Query (I'm using GQL) for an embed, and ask for its aspect ratio

Expected behaviour

Any of

Embedded Assets version

3.2.0

Craft CMS version

4.5.11.1

ttempleton commented 6 months ago

56.25 is what's being returned (e.g. for a YouTube video of size 1920x1080 that I just tested) by the Embed library this plugin uses. If you believe that is incorrect, you'll need to take up the issue with them.

tremby commented 6 months ago

OK. Upstream it's documented as being width/height, but actually calculated as (height/width)*100. I've opened a bug report there.