Skip to content

Commit

Permalink
Add playsInline option in Video block (#14500)
Browse files Browse the repository at this point in the history
* Added the 'playsinline' attribute to the block

* Added output of the 'playsinline' attribute in the front-end

* Added the 'playsinline' attribute in InspectorControls

* Change label 'Playsinline' to 'Plays inline'

* Fix failing e2e test issue

* Replace variable name  to
  • Loading branch information
Nahid F. Mohit authored and gziolo committed Mar 20, 2019
1 parent e0cdf68 commit d6ad848
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/block-library/src/video/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class VideoEdit extends Component {
poster,
preload,
src,
playsInline,
} = this.props.attributes;
const { setAttributes, isSelected, className, noticeOperations, noticeUI } = this.props;
const { editing } = this.state;
Expand Down Expand Up @@ -200,6 +201,11 @@ class VideoEdit extends Component {
onChange={ this.toggleAttribute( 'controls' ) }
checked={ controls }
/>
<ToggleControl
label={ __( 'Play inline' ) }
onChange={ this.toggleAttribute( 'playsInline' ) }
checked={ playsInline }
/>
<SelectControl
label={ __( 'Preload' ) }
value={ preload }
Expand Down
9 changes: 8 additions & 1 deletion packages/block-library/src/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export const settings = {
selector: 'video',
attribute: 'src',
},
playsInline: {
type: 'boolean',
source: 'attribute',
selector: 'video',
attribute: 'playsinline',
},
},

transforms: {
Expand Down Expand Up @@ -144,7 +150,7 @@ export const settings = {
edit,

save( { attributes } ) {
const { autoplay, caption, controls, loop, muted, poster, preload, src } = attributes;
const { autoplay, caption, controls, loop, muted, poster, preload, src, playsInline } = attributes;
return (
<figure>
{ src && (
Expand All @@ -156,6 +162,7 @@ export const settings = {
poster={ poster }
preload={ preload !== 'metadata' ? preload : undefined }
src={ src }
playsInline={ playsInline }
/>
) }
{ ! RichText.isEmpty( caption ) && (
Expand Down
1 change: 1 addition & 0 deletions packages/e2e-tests/fixtures/blocks/core__video.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"controls": true,
"loop": false,
"muted": false,
"playsInline": false,
"preload": "metadata",
"src": "https://awesome-fake.video/file.mp4"
},
Expand Down

0 comments on commit d6ad848

Please sign in to comment.