From 49c715bd0d1631776d233661c7bafffb3963ce9b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 21:23:36 +0000 Subject: [PATCH 1/2] Initial plan From 9d04335fab422074cfff22f47113aa18d2b244b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 5 Mar 2026 21:46:58 +0000 Subject: [PATCH 2/2] Fix portrait video aspect ratio by swapping dimensions when rotation metadata is present Co-authored-by: obenland <1398304+obenland@users.noreply.github.com> --- packages/block-library/src/video/index.php | 54 +++- phpunit/blocks/render-block-video-test.php | 307 +++++++++++++++++++++ 2 files changed, 358 insertions(+), 3 deletions(-) create mode 100644 phpunit/blocks/render-block-video-test.php diff --git a/packages/block-library/src/video/index.php b/packages/block-library/src/video/index.php index 3696bdca3b2e8c..a5f90e192a4aad 100644 --- a/packages/block-library/src/video/index.php +++ b/packages/block-library/src/video/index.php @@ -52,8 +52,24 @@ function render_block_core_video( array $attributes, string $content ): string { return $content; } - $p->set_attribute( 'width', (string) $metadata['width'] ); - $p->set_attribute( 'height', (string) $metadata['height'] ); + /* + * For videos with 90° or 270° rotation metadata (common for portrait videos recorded by + * mobile devices that physically encode frames as landscape with a container-level rotation + * flag), the stored width and height are the pre-rotation dimensions of the video file, not + * the displayed dimensions. Swap them to get the correct displayed dimensions. + * + * The rotation is stored by the `gutenberg_add_video_rotation_to_metadata` filter below, + * which reads it from the raw getID3 data at upload time. + */ + $width = $metadata['width']; + $height = $metadata['height']; + if ( isset( $metadata['rotate'] ) && in_array( abs( (int) $metadata['rotate'] ), array( 90, 270 ), true ) ) { + $width = $metadata['height']; + $height = $metadata['width']; + } + + $p->set_attribute( 'width', (string) $width ); + $p->set_attribute( 'height', (string) $height ); /* * The aspect-ratio style is needed due to an issue with the CSS spec: . @@ -64,17 +80,48 @@ function render_block_core_video( array $attributes, string $content ): string { * } * * This is because this attr() is yet only implemented in Chromium: . + * + * Note: the `auto` keyword cannot be prepended here (i.e. `aspect-ratio: auto W / H`) because + * for `