-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support 'preload' attribute for Video Block #7929
Conversation
core-blocks/video/edit.js
Outdated
@@ -123,6 +124,17 @@ class VideoEdit extends Component { | |||
onChange={ this.toggleAttribute( 'controls' ) } | |||
checked={ controls } | |||
/> | |||
<SelectControl | |||
label={ __( 'Preload' ) } | |||
value={ undefined !== preload ? preload : 'metadata' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would setting a default value for the attribute definition solve the need for this undefined checks?
On the save we would only set the attribute if it was different from the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback, thats a better solution. I committed the change.
@jorgefilipecosta I think it's fine now, can you review it again? |
core-blocks/video/index.js
Outdated
loop={ loop } | ||
muted={ muted } | ||
preload={ preload !== 'metadata' ? preload : null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also apply the property to video element used on edit. So the user may be able to notice some difference (if he had not played the video before).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user adds a video, it preloads by default. When the user changes the preload value, nothing changes because the video is already loaded. If the User selects none
and reloads the page, there is a visible difference.
I think we can add muted
and controls
in a different PR to edit, but preload
in edit is not very useful for the user because there is no visible change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @Soean, I don't think we should add the preload to the edit output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we don't use preload
in edit on the audio block, so best to be consistent and not use it here.
Thank you for the changes @Soean things tested well in my test 👍 I left a minor comment that we may consider addressing before the merge. |
@jorgefilipecosta Thanks for your feedback. I don't think we should add it to edit, see #7929 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all done slightly differently in the Audio block, does it make sense to replicate that approach?
core-blocks/video/index.js
Outdated
loop={ loop } | ||
muted={ muted } | ||
preload={ preload !== 'metadata' ? preload : null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @Soean, I don't think we should add the preload to the edit output.
core-blocks/video/index.js
Outdated
loop={ loop } | ||
muted={ muted } | ||
preload={ preload !== 'metadata' ? preload : null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we don't use preload
in edit on the audio block, so best to be consistent and not use it here.
0f10fa3
to
63cce64
Compare
63cce64
to
21384cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good and I pushed a little update that disables editor interaction with the tag and brings it in line with the audio
component's implementation. I think this is good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scratch that, I'm seeing some block validation fails from earlier blocks, looking into it now.
@tofumatt May I ask you more info regarding the decision of disabling the player controls? While working on #8055 I got used to play the audio file to make sure it was uploaded correctly, so now it feels a bit weird that the player controls don't work anymore. As it is right now, there are no visual clues that those controls don't work (e.g. they are not "grayed out"), and so the player feels broken even if it isn't. |
Right now clicking on the block in any way activates the controls, which is very jarring when the user just means to click on the block to edit it. I ran into this while testing the block in this branch, and we've used a similar pattern elsewhere for things like server-side rendered blocks with HTML comments that, when clicked, will activate a link: https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/latest-comments/edit.js I can see the argument for testing the content, though if it was uploaded and working you'll see a preview frame and length the in the players. I think testing the content is better done in the preview screen, leaving the editing screen to edit/interact with the content in an editing context. If we were to add controls I think they'd be better in the inspector or the toolbar anyway so they're:
If you wanted to see that implemented–feel free to file a bug and we could discuss it further. 😄 EDIT: Oh, and please cc me on the bug. 😅 |
@tofumatt Thanks for the answer! I guess disabled controls are ok per se, but I'd like to know that they are disabled (for example with some disabled style) before clicking on them, panicking, and eventually maybe realize they are just for show. 🙂 |
That's fair! The |
(If you haven't made the issue yet, I can do it actually, sorry!) |
@tofumatt No worries! I'm off for the day but I'll open it first thing tomorrow. |
Too late! 😉 #9252 |
Description
This PR adds the preload attribute to the video block.
As in the Classic editor the default is "metadata" and no attribute is set.
auto
setspreload="auto"
andnone
setspreload="none"
The design is the same as the preload in Audio, see #7590
Gutenberg
![bildschirmfoto 2018-07-12 um 13 20 03](https://user-images.githubusercontent.com/695201/42630534-56ce7c08-85d7-11e8-923c-9946516b5cd1.png)
Classic Editor
![bildschirmfoto 2018-07-12 um 13 21 31](https://user-images.githubusercontent.com/695201/42630556-6ea3b488-85d7-11e8-8ef0-7da593e9c716.png)
related #7501