Needs review
Project:
Drupal core
Version:
main
Component:
file system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Apr 2019 at 08:38 UTC
Updated:
29 Apr 2026 at 22:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
pclaitte commentedComment #3
duaelfrGood job for your first issue! :)
I have a few comments, though.
There is a "N" missing at the beginning of the translatable string.
Options values should follow these rules:
Comment #4
pclaitte commentedComment #5
vadim.hirbu commentedUpdated latest patch according latest comments.
Comment #6
duaelfrThe code looks good.
We should increase the test coverage to ensure that this is working properly and that we will not break it in the future :)
Comment #7
pclaitte commentedComment #8
pclaitte commentedComment #9
pclaitte commentedInstalled and tested on another Drupal 8 instance. It works weel.
Comment #11
idebr commentedI suggest using more objective text explaining what the option does. From the referenced page:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
Comment #13
jnettikA few thoughts on this issue:
FileMediaFormatterBase, since this attribute applies to bothvideoandaudiotags? Other attributes likelooporautoplaylive there.metadata), once it's applied the setting is used by existing files. Sequential config exports will then add the new setting to existing config. Is an update still necessary?I've attached a patch with my suggested changes (minus the description, which I'd be more than happy to add).
Comment #15
jnettikFixed failing test
Comment #16
pclaitte commentedI agree with @jnttik on alls points, or almost :)
I think that a link to Mozilla documentation can be usefull for casual Drupal users.
The Patch #15 works perfectly on fresh install of the last Drupal version.
Comment #17
pclaitte commentedComment #18
alexpottWhat about existing configuration? We need to populate this with a default value - looks like the choice is "metadata". So we need a post update function to use the ConfigEntityUpdater class to add this configuration. We also need a test for it working.
Given there are only three options should this be radios? And maybe a #description is warranted that explains what this setting is about. I don't find the words that self explanatory.
Comment #19
pclaitte commentedYes it can be better. We can transform select to radio list. With this, we allow us to be more verbose for describe the behavior of the new option.
I suggest to take the words of the Mozilla documentation, it's clear. So, we will have a description bloc like this :
This attribute is intended to provide a hint to the browser about what content is loaded before the video is played.
The values list with their descriptions:
Empty value is possible but i don't recommend to allow this because default value can be different between browsers as specified into documentation.
And maybe a conditional activation of preload option. If autoplay option is checked, preload must to be disabled because in this case, browser must to download video or sound for play it.
I'm not sure to understand your advise on the configuration, how can we have existing configuration with a new option ? If it about the existing video fields, we are not sure that user want the "metadata" value and we can't to change it arbitrary. If option is not set on the existing video or audio fields, i think preload attribute doesn't to be present.
Comment #20
alexpott@pclaitte there is existing configuration which does not have the preload configuration. We need a post update function to find this configuration and set it to the default value. If the configuration is optional then we need to handle it differently in the form. With the patch as it stands if you open an existing field formatter config form and, without making any changes, press save it'll change the configuration and that shouldn't happen.
Comment #21
pclaitte commented@alexpott ok i understand. Another way would be to add a defaut empty value into the choices list which, if set, doesn't add the preload attribute. Maybe is it simplest? What do you think about it ?
(sorry for my english)
Comment #22
pclaitte commentedBelow, an example with radio buttons and conditional activation
Comment #23
pclaitte commentedComment #32
pcambra@alexpott I'd love to get this in, I've added @pclaitte changes onto an MR and the following changes:
- Widget is now radios as suggested
- Added short descriptions for the 3 options.
- Added a post update with a config updater
I think the update needs a test but I'd appreciate some guidance on where to find something similar (this has been my first encounter with the config entity updater)
Comment #33
pcambraComment #34
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
This seems like it's going to need an upgrade path for existing settings.
Comment #35
jose reyero commentedPatch looks good to me, already pretty polished...
What I'm wondering about is: how "safe" is to force a default preload attribute value on sites that didn't have any?
I mean, if I had a page full of videos with no 'preload' attribute, maybe just an image placeholder, and suddenly I get that preload=metadata default.... will browsers just start preloading when they didn't before?
The point is: does it make sense to force a default value? or to force any value at all? Should we skip the update script until the user actually edits the formatter?
For background, I've found this pretty interesting post about how browsers behave, but note it is 10 years old, couldn't find and updated one... https://www.stevesouders.com/blog/2013/04/12/html5-video-preload/
Comment #36
pcambraSetting to NR for more input as per #35
Comment #37
smustgrave commentedSee the upgrade path but it needs test coverage. Could be something simple as
Before this value was null
Run updates
This value is now false
Didn’t test the MR
Comment #38
pcambra@smustgrave please see #35 regarding update path.
Comment #39
smustgrave commentedYes the update hook is there but there is no test coverage of it.
See BlockContentUpdateTest for example
Comment #40
pcambra@smustgrave the question in #35 refers to whether we should have the update hook in the first place.
Comment #41
smustgrave commentedSo if I do a config export.
Go into a field or display using this formatterBase.
If I make 0 changes but save the field and do drush export again and it's showing this new setting then yes it will need an update path.
If no then it will not.
The update hook should set to disabled value though.
That help some?
Comment #42
penyaskito@smustgrave "Should we skip the update script until the user actually edits the formatter?" That's exactly what #35 is explaining.
It's ok to assume changes can happen when I save the formatter, but NOT when I just upgrade my site. That could have unexpected consequences, and that's what #35 is asking for feedback from @alexpott.
Comment #43
smustgrave commentedActually the opposite if I save a formatter without making a change and I get changes in my config now that should not be expected.
Same for how we handle other field changes but will let alexpott respond.
Comment #44
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #45
catchI only scanned the MR quickly, but I couldn't see the a presave hook to update shipped config (i.e. default config in modules), that should happen as well as the update function.
We need to update the configuration to something in both post update and presave, so that sites don't get unexpected config changes in runtime - better if they get them during a core update which is when they'll be looking for them.
So.. I think it comes down to what a non-intrusive update looks like - i.e. should it be 'metadata' or 'none', or do a need an additional option for 'unspecified' to preserve current behaviour and update sites to that?
Didn't look around for docs on browser behaviour yet so not sure what the answer is, but definitely we should update to something here.
Comment #47
mrshowermanRebased 10.1.x into MR; providing patch for 9.5 in case anyone needs it.
Leaving in NW as per #45.
Comment #48
catchComment #49
heddn#3309016: Add image preload option to help boost actual and perceived performance is doing some similar things for images. It also has some of the bits around update hooks that are being asked about in #40 and below. For already committed code, look at what
ResponsiveImageConfigUpdateris doing.Can we update the IS to differentiate between what _this_ issue is doing vs #3309016?
Comment #53
mrshowermanCreated MR against 11.x. Adding patch for 10.3.x.
Comment #54
wmfinck commentedHas this not been implemented? If so, how do I find it? I do not want to apply a patch for something that won't show up in production. But I am sorry for wasting anyone's time if I am missing something...
I have no preload options at /admin/structure/media/manage/audio/display
Not being able to prevent preloading of media in D10 is a deal-breaker for me, I cannot use Drupal media. I create sites with audio library pages using views, and when a page of multiple audio files is displayed, sometimes dozens, I cannot have them all downloading.
For this reason, I am compelled to retain the method I used in Drupal 7, which was to create fields with preconfigured HTML5 code using tokens. Doing that I need a file field and two text fields for every audio file (the easiest way without making a custom module, as I am not a developer).
Comment #61
sleitner commentedAfter adding a poster image to video files in #2954834: Add poster image to HTML5 media videos with
requireKey: false, the preload option do not need an updater and updater test coverage as well?Comment #63
sleitner commented