Skip to content

Commit

Permalink
fix advanced video aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-shafi committed Jun 13, 2024
1 parent 7b4a324 commit 0daf984
Show file tree
Hide file tree
Showing 8 changed files with 134,525 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/blocks.build.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'bd7ea8b719276178d361');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '5976fc4ce0d71acb1d58');
134,485 changes: 134,484 additions & 1 deletion dist/blocks.build.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/blocks.build.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/priority.build.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '31d6cfe0d16ae931b73c');
<?php return array('dependencies' => array(), 'version' => 'bf4427955793c56378a0');
9 changes: 9 additions & 0 deletions dist/priority.build.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ That's it. You're done!

== Changelog ==

= 3.2.0 =

* FIX: Aspect Ratio not working on uploaded video in advanced video block.

= 3.1.9 =

* FIX: Steps not saving in the how to block.
Expand Down
17 changes: 16 additions & 1 deletion src/blocks/advanced-video/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,21 @@ export function AdvancedVideoBlock(props) {
);
extraEmbeds = null;
break;
case "unknown":
const localAspectRatio =
!isEmpty(aspectRatio) && aspectRatio !== "auto"
? aspectRatio
: `${origWidth}/${origHeight}`;
extraEmbeds = (
<style>
{`#ub-advanced-video-${blockID}.ub-advanced-video-autofit video{
aspect-ratio: ${localAspectRatio};
height: auto !important;
object-fit:cover;
}`}
</style>
);
break;
default:
autofitContainerStyle = {};
extraEmbeds = null;
Expand All @@ -776,7 +791,7 @@ export function AdvancedVideoBlock(props) {
const newHeight = media.height;
let timeUnits = [0];
const conversionFactor = [1, 60, 3600, 86400];
console.log({ media, newHeight, newWidth });

if (!isEmpty(media?.fileLength)) {
timeUnits = media.fileLength
.split(":")
Expand Down
9 changes: 9 additions & 0 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ function ub_include_block_attribute_css() {
'padding-bottom: ' . ( $attributes['origHeight'] / $attributes['origWidth'] * 100 ) . '%;' .
'}';
break;
case 'unknown':
$local_aspect_ratio = !empty($attributes['aspectRatio']) && $attributes['aspectRatio'] !== 'auto' ? $attributes['aspectRatio'] : $attributes['origWidth'] . '/' . $attributes['origHeight'];
$blockStylesheets .= $prefix . ' .ub-advanced-video-embed > video{' .
'aspect-ratio: ' . $local_aspect_ratio . ';' .
'height: auto !important;
object-fit: cover;
' .
'}';
break;
default:
$blockStylesheets .= '';
}
Expand Down

0 comments on commit 0daf984

Please sign in to comment.