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
Responsive themes (including Drupal 8 core themes) will require using a variety of image sizes at different resolutions, so
- Images are optimized for screen and bandwidth.
- Anonymous page caching will work out-of-the-box.
- Other modules can easily alter the output for.
Proposed Resolutions
- Implement the still to be approved picture element so Drupal is using the latest technology at the time of release, by the looks of it (http://www.w3.org/community/respimg/2012/08/04/picture-in-the-html5-spec/) this will be solved in a timely matter, well before Drupal 8 is released.
- Implement it as a separate module so user can decide if they need it or not. This also gives contrib the possibility to come up with something better.
- Picture acts as a new display formatter for existing image fields.
- Focus on image fields first, but make it easy to support media, inline images as well.
- For the moment all modern browsers are working (so not IE8-).
Remaining tasks
- Write full documentation for picture.
Original report by [Jeff Burnz]
see #1170478: Responsive Images for the background discussion
Related discussions
- #1734642: Move breakpoint module into core
- #1170478: Responsive Images
- http://www.w3.org/html/wg/tracker/actions/220?changelog
- http://www.w3.org/community/respimg/ and http://www.w3.org/community/respimg/wiki/Picture_Element_Proposal
- https://www.w3.org/Bugs/Public/show_bug.cgi?id=18384
- Drupal 8 Mobile Initiative meeting #13
- http://dvcs.w3.org/hg/html-proposals/raw-file/tip/responsive-images/resp...
Polyfills for browsers not supporting <picture>
- https://github.com/attiks/picturefill-proposal based on https://github.com/Wilto/picturefill-proposal
- https://github.com/paulirish/matchMedia.js/
Browser support
- For the moment no native support, but some big companies are helping out on the proposal
- Polyfill works in modern browsers (IE9+)
- IE8 isn't working, because is doesn't understand media queries
- The fallback should work in all browsers and can be configured, the default fallback is the mobile variant, but this can be changed.
Comment | File | Size | Author |
---|---|---|---|
#68 | i1775530-68.patch | 9.65 KB | attiks |
#68 | interdiff.txt | 4.39 KB | attiks |
#62 | i1775530-62.patch | 6.37 KB | attiks |
#60 | i1775530-60.patch | 7.3 KB | attiks |
#53 | picture-53.patch | 52.6 KB | attiks |
Comments
Comment #1
klonosI realize there's talk about dropping IE8 support in D8, but wouldn't this work in IE8 too if a polyfill (like matchmedia.js for example) was used?
Comment #2
effulgentsia CreditAttribution: effulgentsia commentedIn #1465948: [meta] Drop some IE8 coddling from Drupal core and #1645494: Allow core themes to display single-column on IE8: do not compensate for lack of media query support, we decided that it is not core's responsibility to compensate for IE8's lack of media query support: that IE8 falling back to mobile layouts (and by extension, image variants) is ok. So I'd like to restate #1 as: if a contrib module like Respond.js were enabled, would the picture polyfill work on IE8, or would something else be needed, and if so, what?
Comment #3
attiks CreditAttribution: attiks commented#1 the polyfill uses matchmedia.js to do its magic, but mactmedia only works on browser that support media queries
#2 at least for picture the fallback can be choosen, it defaults to mobile, but can be changed. Some themes (like omega) use something comparable to fix the IE9- problem.
Respond.js has adds limited support for media queries in IE9-: "support for min-width and max-width CSS3 media queries" and it adds extra request to analyze the css, so it will not work with most media queries. AFAIK there's no proper way to add support to those browsers, unless we write something on our own.
Comment #4
wilto CreditAttribution: wilto commentedHey, just figured I’d chime in. I know supporting IE8 is a much larger discussion, but as far as Picturefill goes: Scott Jehl, Paul Irish, and Nicholas Zakas whipped-up an awesome
matchMedia
polyfill that we’ve thoroughly tested with Picturefill.https://github.com/scottjehl/matchMedia.js
Comment #5
attiks CreditAttribution: attiks commentedTargeting IE8 is possible if you build your media query in the right way: "screen, all and (min-width: 560px) and (max-width:850px)" can be used to target IE8/IE7
The demo is updated as follows:
Comment #6
attiks CreditAttribution: attiks commentedpatch, sandbox at http://drupal.org/sandbox/attiks/1800924, branch
Comment #8
attiks CreditAttribution: attiks commentedTests will keep failing since this depends on breakpoints functionality #1734642: Move breakpoint module into core
Comment #9
attiks CreditAttribution: attiks commentedNew patch including the breakpoint patch so it can be tested.
Comment #10
attiks CreditAttribution: attiks commentednew patch after renaming of breakpoint, also added tests for picture output
Comment #11
attiks CreditAttribution: attiks commentedmissed one rename
Comment #12
attiks CreditAttribution: attiks commentedmore renaming, feel free to review the picture part
Comment #13
attiks CreditAttribution: attiks commentednew patch, removing wrapper functions
Comment #14
attiks CreditAttribution: attiks commentednew patch, using latest version of the breakpoint patch
Comment #15
attiks CreditAttribution: attiks commentedsome minor fixes
Comment #17
attiks CreditAttribution: attiks commentedComment #18
attiks CreditAttribution: attiks commentedComment #19
attiks CreditAttribution: attiks commentedProposal can be found at http://wilto.github.com/draft-prop/ResponsiveImages.html
At the bottom of that page you can find all open issues.
Comment #20
attiks CreditAttribution: attiks commentedImplemented display formatter as plugin #1785748: Field formatters as plugins
Comment #21
attiks CreditAttribution: attiks commentedPatch against core now that breakpoint is added.
Firstly for the bot, but feedback appreciated.
Comment #22
attiks CreditAttribution: attiks commentedoops
entity_create
move to page callback
new line
add hook_help
add something for duplicate as well
should an uncompressed copy be added as well?
Comment #23
attiks CreditAttribution: attiks commentednew patch for #22
Comment #23.0
attiks CreditAttribution: attiks commentedUpdated issue summary.
Comment #24
attiks CreditAttribution: attiks commentedNew patch using matchmedia from #1815602: Introduce a polyfill for matchMedia
Comment #25
Shyamala CreditAttribution: Shyamala commentedAs I understand the Picture module facilitates mapping of image caches to different groups of breakpoints.
Steps followed to configure Picture module and test the same:
The Configured breakpoints did not seem to apply! Is there any configuration that I have missed?
Comment #26
attiks CreditAttribution: attiks commentedYou need to apply to patch from #1815602-43: Introduce a polyfill for matchMedia that should fix it.
If that doesn't help, can you paste the output of the picture?
Thanks
Comment #27
Shyamala CreditAttribution: Shyamala commentedOutput for the picture:
Also attached screen shot of configuration & updated steps at #25
Comment #28
attiks CreditAttribution: attiks commented#27 that output is the default image output, did you press 'Save' on admin/structure/types/manage/article/display after changing it to picture?
Comment #29
Shyamala CreditAttribution: Shyamala commentedLooks like I did not click on save. It's working fine now.
Shouldn't there must be an alert to the user requesting him to click on save? I only used the update button!
Works perfectly on all breakpoints.
Comment #30
Shyamala CreditAttribution: Shyamala commentedWorks perfectly on following the steps at #25.
Comment #31
attiks CreditAttribution: attiks commented#29 I think a message would be fine, but it's a problem with all field formatters, can you create a new issue for it?
BTW thanks for testing.
Comment #32
webchickI believe we need #1815602: Introduce a polyfill for matchMedia in first, so marking this postponed.
Comment #33
attiks CreditAttribution: attiks commentedmatchmedia polyfill is committed, back to NR for an in depth code review
Comment #34
attiks CreditAttribution: attiks commentedThis needs a reroll because of #1763974: Convert entity type info into plugins
Comment #35
attiks CreditAttribution: attiks commentedThis needs a reroll because of #1763974: Convert entity type info into plugins
Comment #36
attiks CreditAttribution: attiks commentedNew patch without hook_entity_info
Comment #38
tim.plunkett#36: picture-36.patch queued for re-testing.
Comment #40
attiks CreditAttribution: attiks commentedNew patch to fix the test use statements
Comment #42
attiks CreditAttribution: attiks commentedgrrrr
Comment #44
attiks CreditAttribution: attiks commentedwe're getting there.
Comment #46
attiks CreditAttribution: attiks commentedbot failing on userpicture
Comment #47
attiks CreditAttribution: attiks commentedthank you bot ;-)
Comment #48
moshe weitzman CreditAttribution: moshe weitzman commentedTested this and it works really nicely. This is going to be fantastic.
Duplicate Doxygen
Comment #49
larowlanIf you reroll for #48
+ // Create user. + $this->admin_user = $this->drupalCreateUser(array('administer pictures', 'access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles')); + $this->drupalLogin($this->admin_user);
Can these go one per line as per coding standards
Oh and this is awesome btw!
Comment #50
attiks CreditAttribution: attiks commentedNew patch addressing #48, #49
Comment #51
moshe weitzman CreditAttribution: moshe weitzman commentedThanks
Comment #52
webchickLike we did with mediaMatcher, let's point this at a Drupal URL rather than a github URL for one specific individual (especially one with "proposal" in the name :D)
We need to make sure these functions all have PHPDoc above them, as well as @param / @return docs. Part of the docs gate.
Apart from this, great work! happy to commit it. :)
Comment #53
attiks CreditAttribution: attiks commentednew patch addressing #52 and some white space issues.
Back to RTBC.
Comment #54
webchickCommitted and pushed to 8.x. YAY! :D
Comment #55
yched CreditAttribution: yched commentedCouple remarks on the code that got committed :
Whitespace slipped in.
indent issue - and not clear where that if block ends
leftover commented line ?
Why should this have a dependency on config.module ? config.module is only about config UI, not about the config system
Sentence should be capitalized
Ditto.
Ditto, plus missing trailing point - plus, that's not a real sentence :-)
Comment #56
tim.plunkettAlso, can the picture.info description be expanded past "Picture element"? That doesn't tell me much.
Comment #57
Eric_A CreditAttribution: Eric_A commentedNeeds a follow-up for coding standard issues.
All of these should be like:
More of these around that should be third person.
Comment #58
Eric_A CreditAttribution: Eric_A commentedCross post. Restoring status.
Comment #59
attiks CreditAttribution: attiks commentedworking on this
Comment #60
attiks CreditAttribution: attiks commentedNew patch for #55, #56 and #57
Comment #61
tim.plunkettI don't know if the bot can read that patch, but I can't. :)
Comment #62
attiks CreditAttribution: attiks commented#61 A more readable version
Comment #63
attiks CreditAttribution: attiks commentedComment #64
yched CreditAttribution: yched commentedlooks good, thanks !
(checked with @alexpott that picture and breakpoint indeed have no reason to depend on config.module)
Comment #66
attiks CreditAttribution: attiks commentedretested, bot is a bit sleepy
Comment #67
yched CreditAttribution: yched commentedgreen
Comment #68
attiks CreditAttribution: attiks commentedI reviewed the documentation with @jhodgdon
Comment #69
attiks CreditAttribution: attiks commentedStill RTBC if bot is happy.
Comment #70
tim.plunkettNote: The interdiff is backwards :)
But the current patch looks good.
Comment #71
webchickCommitted and pushed to 8.x.
Comment #72
attiks CreditAttribution: attiks commentedFYI: Follow up created to handle AJAX requests: #1836860: Picture doesn't work with AJAX callback
Comment #74
moshe weitzman CreditAttribution: moshe weitzman commentedDo we have issues open for actually using this by default? I would think we want to ship with picture enabled in standard install and picture formatter on the image fields in Article content type and on User entity (i.e. user picture).
Comment #75
attiks CreditAttribution: attiks commented#74 AFAIK there are no issues created yet, it would be nice to enable and use it by default.
Comment #76
attiks CreditAttribution: attiks commented#74 see #1855412: Enable responsive_image.module by default for standard install profile
Comment #76.0
attiks CreditAttribution: attiks commentedUpdated issue summary.