Skip to content

Commit

Permalink
VideoPress: check if beta extension is enabled when saving VideoPress…
Browse files Browse the repository at this point in the history
… video block (#29926)

* [not verified] check if beta extension is enable when saving

* [not verified] changelog
  • Loading branch information
retrofox authored Apr 5, 2023
1 parent 63d457e commit 0184dbe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

VideoPress: check if beta extensions are enabled when saving VideoPress video block
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getVideoPressUrl } from '../../../lib/url';
/**
* Types
*/
import { isVideoFramePosterEnabled } from './components/poster-panel';
import type { VideoBlockAttributes } from './types';
import type React from 'react';

Expand Down Expand Up @@ -52,11 +53,16 @@ export default function save( { attributes }: videoBlockSaveProps ): React.React
} ),
} );

const isPreviewOnHoverEnabled = isVideoFramePosterEnabled();

const autoplayArg = ! isPreviewOnHoverEnabled ? autoplay : autoplay || posterData.previewOnHover;
const mutedArg = ! isPreviewOnHoverEnabled ? muted : muted || posterData.previewOnHover;

const videoPressUrl = getVideoPressUrl( guid, {
autoplay: autoplay || posterData.previewOnHover, // enabled when `previewOnHover` is enabled.
autoplay: autoplayArg,
controls,
loop,
muted: muted || posterData.previewOnHover, // enabled when `previewOnHover` is enabled.
muted: mutedArg,
playsinline,
preload,
seekbarColor,
Expand All @@ -73,6 +79,22 @@ export default function save( { attributes }: videoBlockSaveProps ): React.React
style.margin = 'auto';
}

if ( ! isVideoFramePosterEnabled() ) {
return (
<figure { ...blockProps } style={ style }>
{ videoPressUrl && (
<div className="jetpack-videopress-player__wrapper">
{ `\n${ videoPressUrl }\n` /* URL needs to be on its own line. */ }
</div>
) }

{ ! RichText.isEmpty( caption ) && (
<RichText.Content tagName="figcaption" value={ caption } />
) }
</figure>
);
}

return (
<figure { ...blockProps } style={ style }>
{ videoPressUrl && (
Expand Down

0 comments on commit 0184dbe

Please sign in to comment.