-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VideoPress: Add video settings to the VideoPress-enhanced video block (…
…#13134) Add the video settings allowing to customize several options for the VideoPress player rendered by the video block (extended by our VideoPress extension for Gutenberg). Now, after inserting a VideoPress-enhanced video block, a user can set the following settings: - Autoplay: whether to start playing as soon as the player renders (note that some browsers can prevent a video from being autoplayed). - Loop: whether to loop the video. - Muted: whether the video should start in a muted state. - Playback controls: whether show the controls to allow the user to control video playback. - Preload: what content is loaded before the video is played: - None: Indicates that the video should not be preloaded. - Metadata: Indicates that only video metadata (e.g. length) is fetched. - Auto: Indicates that the whole video file can be downloaded, even if the user is not expected to use it. - Poster image: image to be shown while the video is downloading. Given that these settings modifies the URL saved in the block content, any existing post containing a VideoPress-enhanced video block would result in a "invalid content" error. In order to support those posts, a deprecated version of the block has been added. These changes also introduces a new `playsInline` attribute (added in core in WordPress/gutenberg#14500), but it's currently unmodifiable, since VideoPress doesn't support it yet.
- Loading branch information
Showing
6 changed files
with
311 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import save from './save'; | ||
|
||
export default { | ||
attributes: { | ||
autoplay: { | ||
type: 'boolean', | ||
}, | ||
caption: { | ||
type: 'string', | ||
source: 'html', | ||
selector: 'figcaption', | ||
}, | ||
controls: { | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
guid: { | ||
type: 'string', | ||
}, | ||
id: { | ||
type: 'number', | ||
}, | ||
loop: { | ||
type: 'boolean', | ||
}, | ||
muted: { | ||
type: 'boolean', | ||
}, | ||
poster: { | ||
type: 'string', | ||
}, | ||
preload: { | ||
type: 'string', | ||
default: 'metadata', | ||
}, | ||
src: { | ||
type: 'string', | ||
}, | ||
}, | ||
support: { | ||
reusable: false, | ||
}, | ||
save, | ||
isDeprecation: true, | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { RichText } from '@wordpress/editor'; | ||
|
||
export default function VideoPressSave( { attributes } ) { | ||
const { caption, guid } = attributes; | ||
|
||
if ( ! guid ) { | ||
return null; | ||
} | ||
|
||
const url = `https://videopress.com/v/${ guid }`; | ||
|
||
return ( | ||
<figure className="wp-block-embed is-type-video is-provider-videopress"> | ||
<div className="wp-block-embed__wrapper"> | ||
{ `\n${ url }\n` /* URL needs to be on its own line. */ } | ||
</div> | ||
{ ! RichText.isEmpty( caption ) && ( | ||
<RichText.Content tagName="figcaption" value={ caption } /> | ||
) } | ||
</figure> | ||
); | ||
} |
This file contains 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
Oops, something went wrong.