Video block: Fix incorrect aspect ratio for portrait videos with rotation metadata#76220
Draft
Video block: Fix incorrect aspect ratio for portrait videos with rotation metadata#76220
Conversation
…metadata is present Co-authored-by: obenland <1398304+obenland@users.noreply.github.com>
|
Flaky tests detected in 49c715b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22737399016
|
Copilot
AI
changed the title
[WIP] Fix aspect ratio for portrait videos in Video block
Video block: Fix incorrect aspect ratio for portrait videos with rotation metadata
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Portrait videos encoded in landscape orientation with a container-level rotation flag (common on mobile devices) render with a swapped aspect ratio on the front end. The inline
aspect-ratio: 1920 / 1080style added byrender_block_core_videouses the physical (pre-rotation) dimensions fromwp_get_attachment_metadata(), whichwp_read_video_metadata()populates from getID3's rawresolution_x/resolution_y— neither of which accounts for rotation.Why
aspect-ratio: auto W / His not the fixThe obvious candidate — prepending
auto— doesn't work. Per the HTML spec and CSSWG issue #7524,<video>has a defined default object size of 300×150 that is always treated as the element's natural aspect ratio before video data loads.autotherefore resolves to300/150before loading rather than falling back toW/H, reintroducing the CLS that the inline style was specifically introduced to prevent.Root cause
getID3 does compute the rotation from the QuickTime
tkhdatom's transform matrix and stores it in$data['video']['rotate'], butwp_read_video_metadata()never extracts it into the stored attachment metadata.Changes
wp_read_video_metadatafilter (gutenberg_add_video_rotation_to_metadata): persists getID3's$data['video']['rotate']into the attachment metadatarotatekey at upload time. Does not overwrite arotatevalue already present.render_block_core_video: whenrotateis±90or±270, swapswidth/heightbefore writing thewidth/heightHTML attributes and theaspect-ratioinline style:Limitation
Videos already in the media library will not have the
rotatekey in their stored metadata until attachment metadata is regenerated (e.g. re-upload orwp media regenerate). Newly uploaded videos are fixed automatically.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
caniuse.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)developer.wordpress.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)drafts.csswg.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)https://api.github.com/graphql/usr/bin/gh gh pr view 70293 --json body,title,comments(http block)https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c216317e96c8b3f5932808f9b0f1f7a14e3bbf55/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/244d7b04fc4bc2117c15f5abe23eb933b5f02bbf/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/7c8d18b4d90dac9e86b0869a608fa09158e168fa/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/clue/reactphp-term/zipball/00f297dc597eaee2ebf98af8f27cca5d21d60fa3/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/clue/reactphp-utf8/zipball/d5cd04d39cb5457aa5df830b7c4b301d2694217e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/installers/zipball/12fb2dfe5e16183de69e784a7b84046c43d97e8e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/jolicode/php-os-helper/zipball/e71596ae67d477fe214a5908f5522b9e4d19fd37/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/reactphp/event-loop/zipball/ba276bda6083df7e0050fd9b33f66ad7a4ac747a/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/exporter/zipball/14c6ba52f95a36c3d27c835d65efc7123c446e8c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/rV4vwg /usr/bin/composer install --no-interaction(http block)weston.ruter.net/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.