Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Embedding the iframe in the page can result in a fairly large amount of assets and http requests that may not be needed if the user doesn't watch the video
Proposed resolution
Add a lazy load formatter that displays a thumbnail that when clicked, swaps the thumbnail for the video, triggering the iframe load and bandwidth etc.
This is similar to the colorbox formatter.
Before
After
Screenshot showing play button styling/treatment
Remaining tasks
Get test green
Review
User interface changes
None
API changes
New formatter
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff.txt | 30.99 KB | Sam152 |
#15 | add_a_lazy_load_formatter-2888635-15.patch | 13.42 KB | Sam152 |
| |||
#13 | interdiff.txt | 33.6 KB | Sam152 |
#13 | add_a_lazy_load_formatter-2888635-13.patch | 42.7 KB | Sam152 |
#2 | add_a_lazy_load_formatter-2888635-2.patch | 11.33 KB | larowlan |
Comments
Comment #2
larowlanComment #3
larowlanComment #4
Sam152 CreditAttribution: Sam152 commentedThis looks awesome. Lets add at least one entry to FieldOutputTest and then we're good to go.
Left over?
Comment #5
Sam152 CreditAttribution: Sam152 commentedHead is fixed. #2888653: Fix HEAD
Comment #6
dmegatool CreditAttribution: dmegatool commentedI applied against the dev version but getting some php error... Is this working ? Do I need to apply the "Fix Head" patch too ?
Comment #7
Sam152 CreditAttribution: Sam152 commentedThe other patch is already merged. You should be able to do a pull and then apply the patch. It's helpful to post the error you are getting if you're asking for help in fixing it :)
Comment #8
dmegatool CreditAttribution: dmegatool commentedEdit : Unrelated error. Decluttering the thread...
Comment #9
Sam152 CreditAttribution: Sam152 commentedVideo embed field isn't in your callstack, so unlikely to be the issue. Have you removed the "photoswipe" without uninstalling it first?
Comment #10
dmegatool CreditAttribution: dmegatool commentedI thought the patch could have broken something with formatters... I ended up removing and reinstalling photoswipe and the error is gone, weird. Got it working now ! Gotta fix my css but this look very promising. Thank you very much for the help ;)
Comment #11
dmegatool CreditAttribution: dmegatool commentedThat patch is perfectly working work me, in the all the views I had the video embed formatter... Works across the board in all my tests. Thanks again !
Comment #12
Sam152 CreditAttribution: Sam152 commentedClearly lots of demand for a formatter like this. I'll look at #4 and get this in when I can.
Comment #13
Sam152 CreditAttribution: Sam152 commentedFixing #4 and resolving some issues I had with manual testing.
Comment #14
Sam152 CreditAttribution: Sam152 commentedExplaining some of the changes.
This was required because for image styles smaller than the width of the container the video was in, the play button would appear off centre. Stretching the image seems appropriate, the container can either be made smaller or the image style can be made larger.
Lazyload doesn't work without responsive-video, so enforcing this at the library level instead of adding both.
Viewing as logged out user, it said "Drupal" wasn't defined. This seems like the right library to make sure all the stuff we need is there.
Comment #15
Sam152 CreditAttribution: Sam152 commentedRe-enabling tests I disabled in the last patch.
Comment #16
Sam152 CreditAttribution: Sam152 commentedComment #19
drc0 CreditAttribution: drc0 commentedHello, is that possible for the lazy load formatter to replace the image thumbnail with the actual video iframe?
edit:
as usual check for js errors before issuing a comment, the formatter works as intended!