My theme has nine potential breakpoints defined in it.
<ul>
<li>mobile: (min-width: 0px)
<li>mobileland: all and (min-width: 21em)</li>
<li>mobilewide: all and (min-width: 28.5em)</li>
<li>tabport: all and (min-width: 46.5em)</li>
<li>tabland: all and (min-width: 55.5em)</li>
<li>desk: all and (min-width: 65em)</li>
<li>wide: all and (min-width: 73.5em)</li>
<li>huge: all and (min-width: 91.5em)</li>
<li>giant: all and (min-width: 109.5em)</li>
</ul>
On the breakpoints configuration page, I turned on the 2x multipliers for each of those breakpoints. I then created three breakpoint groups:
<ul>
<li>Aside</li>
<li>Full</li>
<li>Non-aside</li>
</ul>
Each group has a subset of the total potential breakpoints. For example, Aside and Non-aside use five of the breakpoints, while full uses seven of the breakpoints. Again, each of them has the 2x multipliers turned on.
I have nine image styles for the various widths to use for those breakpoints. The title of each style corresponds to the width the image will be scaled to:
<ul>
<li>resp-240</li>
<li>resp-320</li>
<li>resp-420</li>
<li>resp-480</li>
<li>resp-640</li>
<li>resp-840</li>
<li>resp-960</li>
<li>resp-1280</li>
<li>resp-1680</li>
</ul>
Then in the responsive images and styles configuration, I assign those image styles to the appropriate breakpoints and their 2x versions. For example, for Aside, I have the following assignments:
<ul>
<li>1x mobile: resp-320</li>
<li>2x mobile: resp-640</li>
<li>1x mobileland: resp-480</li>
<li>2x mobileland: resp-960</li>
<li>1x mobilewide: resp-320</li>
<li>2x mobilewide: resp-640</li>
<li>1x tabport: resp-240</li>
<li>2x tabport: resp-480</li>
<li>1x giant: resp-320</li>
<li>2x giant: resp-640</li>
</ul>
However, when the picture element code is output, and this is true regardless of how the image is selected (Media WYSIWYG integration, choosing the responsive image Aside format, or simply an image field set to the responsive image Aside format), this does not match the actual breakpoints and image styles that are output:
<picture class="resp-img-picture" alt="" title="">
<!-- <source media="(min-width: 0px)" alt="" class="media-image resp-img-picture resp-img-picture-mobile" width="640" typeof="foaf:Image" src="http:///sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" /> -->
<source media="(min-width: 0px)" alt="" class="media-image resp-img-picture resp-img-picture-mobile" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 21em)" alt="" class="media-image resp-img-picture resp-img-picture-mobileland" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-960/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 21em)" alt="" class="media-image resp-img-picture resp-img-picture-mobileland" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-960/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 28.5em)" alt="" class="media-image resp-img-picture resp-img-picture-mobilewide" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 28.5em)" alt="" class="media-image resp-img-picture resp-img-picture-mobilewide" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 46.5em)" alt="" class="media-image resp-img-picture resp-img-picture-tabport" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 46.5em)" alt="" class="media-image resp-img-picture resp-img-picture-tabport" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 55.5em)" alt="" class="media-image resp-img-picture resp-img-picture-tabland" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 55.5em)" alt="" class="media-image resp-img-picture resp-img-picture-tabland" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 65em)" alt="" class="media-image resp-img-picture resp-img-picture-desk" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 65em)" alt="" class="media-image resp-img-picture resp-img-picture-desk" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 73.5em)" alt="" class="media-image resp-img-picture resp-img-picture-wide" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 73.5em)" alt="" class="media-image resp-img-picture resp-img-picture-wide" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 91.5em)" alt="" class="media-image resp-img-picture resp-img-picture-huge" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 91.5em)" alt="" class="media-image resp-img-picture resp-img-picture-huge" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-480/public/garbage-pile-banner_6.jpg" />
<!-- <source media="all and (min-width: 109.5em)" alt="" class="media-image resp-img-picture resp-img-picture-giant" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" /> -->
<source media="all and (min-width: 109.5em)" alt="" class="media-image resp-img-picture resp-img-picture-giant" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" />
<noscript><img alt="" class="media-image resp-img-picture resp-img-picture-mobile" width="640" typeof="foaf:Image" src="/sites/default/files/styles/resp-640/public/garbage-pile-banner_6.jpg" /></noscript>
</picture>
As you can see, all breakpoints are used, even if the responsive image group only uses a subset of the theme’s breakpoints. As well, none of the 2x versions are used. srcset is not showing up.
It appears that each breakpoint is using the image style assigned to the 2x version, rather than the 1x version.
Also, each source element is being listed twice, the first time escaped. That should not be necessary.
Hope we can get this cleared up fairly easily.
Comments
Comment #1
attiks CreditAttribution: attiks commentedThe easy part: "Also, each source element is being listed twice, the first time escaped. That should not be necessary." It is for the polyfill to work.
You're absolutely sure you select the right output formatter?
Comment #2
RainbowArrayYes, I'm selecting the right output formatter.
For an image field, the output is the same whether I'm using the image formatter or the rendered file formatter. And yes, I've double-checked the settings on the file types configuration page for images inserted via the Media module and WYSIWYG.
Something is off.
Comment #3
RainbowArrayI just installed the latest dev versions of resp_img and breakpoints, and I'm still seeing the same errors:
These are picture elements inserted into the content area with the Media module.
For picture elements inserted via an image field, the second and third items are still true. Different widths are applied to each source element, but based on the 2x image style for that breakpoint: the 1x width is ignored.
This is an important bug, because only retina-quality images are being output, quadrupling the page weight of responsive images, which is counter-productive on mobile devices, or on any device.
Comment #4
Jelle_SFixed in latest dev. You will need the latest dev of Breakpoints as well. And don't forget to run update.php :-)
Comment #5
RainbowArrayHmmm. Latest dev versions installed, update.php has run.
I'm not sure what happened, but at least initially, I'm not even getting a picture element in my HTML output now.
This is the error message I'm seeing:
Notice: Undefined variable: group_name in resp_img_field_attach_view_alter() (line 261 of /sites/all/modules/contributed/resp_img/resp_img.module).
I've taken a look at the breakpoints configuration page and the responsive image styles configuration page, and all looked well. I'll check the Media and field configuration pages next.
Comment #6
RainbowArrayNone of the responsive image styles are showing up in the file types > manage display or file types > manage file display configuration pages. That's probably part of the problem.
Comment #7
Jelle_SIf you go to admin/config/media/file-types/manage/image/file-display and you check the 'Image' checkbox you should see the responsive image styles in the 'Image' vertical tab in the 'Image style' select box. Can you confirm?
Comment #8
RainbowArrayNo, they're not showing up there. Pretty sure that's the source of the problem.
Comment #9
RainbowArrayWith the latest dev version, the responsive image styles are showing up correctly on the file display pages, and the picture element is now properly output on the page.
Also:
However, the same width and height attributes are still being output on every source element.
Comment #10
attiks CreditAttribution: attiks commentedComment #11
Jelle_SThe ouput seems right to me... I followed your steps described in the issue summary (starting from a clean install).
I tested with the Aside group you described.
So after creating the breakpoint groups, image styles and mappings between them here's what I did:
Here's what the mapping looks like:
And here's the generated output:
As far as I can see, the media queries match the widths and heights in the picture element. Can you confirm?
Comment #12
Jelle_SComment #13
attiks CreditAttribution: attiks commentedAssuming this is fixed