As per a discussion with webchick, the usability of the responsive images UI would be greatly improved if there were intelligent defaults that site builders could select.

Problem/Motivation

Responsive images can be complicated, particularly when using sizes for viewport sizing, even though that is the best practice. While we have a patch that cleans up the UI and improves the help text, having site builders start from scratch makes it intimidating to actually use responsive images.

Proposed resolution

Provide a default breakpoint group called viewport sizing with an empty breakpoint that can be used for this primary use case. Create two default responsive image styles, wide and narrow, which can be used in main content areas and sidebars (or floated in main content areas) accordingly. These will require at least two new image styles so images will look good on high-resolution screens.

While these responsive image styles may not be ideal for every theme layout, that is also true for the default image styles in core. This at least provides examples that may work reasonably well.

Remaining tasks

- Create default breakpoint group and breakpoint in Breakpoint module
- Create new default image styles
- Create default responsive image styles in Responsive Image module

User interface changes

This will provide default options for those using responsive images.

API changes

None.

Data model changes

None.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because this is required for a major issue (https://www.drupal.org/node/2334387) that is a follow-up to a recent critical change (https://www.drupal.org/node/2260061)
Issue priority Major because this is required for another major, which is a follow-up to a recent critical change. This greatly improves the UX of using responsive images.
Prioritized changes The main goal of this issue is improve usability for the new sizes attribute. Making this easier to use will give Drupal 8 full ability to make use of the responsive images specification, which ultimately means better front-end performance for Drupal 8 sites. This is also a follow-up change to a recent critical, https://www.drupal.org/node/2260061./td>
Disruption This adds new defaults but does not change existing defaults.
CommentFileSizeAuthor
#70 2513604-70-responsive-image-defaults.patch12.32 KBrainbowarray
#59 interdiff-2513604-56-59.txt912 bytesrainbowarray
#59 2513604-59-responsive-image-defaults.patch12.23 KBrainbowarray
#56 2513604.56.patch11.98 KBalexpott
#56 54-56-interdiff.txt4.47 KBalexpott
#54 2513604.54.patch8.56 KBalexpott
#54 51-54-interdiff.txt1.38 KBalexpott
#52 Screen Shot 2015-08-08 at 12.13.32 PM.png17.97 KBrainbowarray
#52 Screen Shot 2015-08-08 at 12.13.20 PM.png20.58 KBrainbowarray
#52 Screen Shot 2015-08-08 at 12.14.07 PM.png14 KBrainbowarray
#52 Screen Shot 2015-08-08 at 12.13.52 PM.png36.88 KBrainbowarray
#52 Screen Shot 2015-08-08 at 12.11.58 PM.png51.63 KBrainbowarray
#51 interdiff.txt442 bytesattiks
#51 i2513604-51.patch8.33 KBattiks
#47 interdiff.txt663 bytesattiks
#47 i2513604-46.patch8.5 KBattiks
#45 interdiff.txt964 bytesattiks
#45 i2513604-45.patch8.07 KBattiks
#43 interdiff.txt1.59 KBattiks
#43 i2513604-43.patch7.29 KBattiks
#42 i2513604-42.patch5.76 KBattiks
#38 i2513604-38.patch4.83 KBattiks
#32 interdiff-2513604-30-32.txt6.91 KBrainbowarray
#32 2513604-32-responsive-image-defaults.patch7.2 KBrainbowarray
#30 interdiff-2513604-25-30.txt5.19 KBrainbowarray
#30 2513604-30-responsive-image-defaults.patch12.21 KBrainbowarray
#26 interdiff-2513604-16-25.txt10.83 KBrainbowarray
#26 2513604-25-responsive-image-defaults.patch12.2 KBrainbowarray
#16 interdiff-2513604-12-16.txt2.07 KBrainbowarray
#16 2513604-16-responsive-image-defaults.patch5.91 KBrainbowarray
#12 2513604-12-responsive-image-defaults.patch5.95 KBjelle_s
#12 interdiff-10-12.txt4.8 KBjelle_s
#10 interdiff-2513604-8-10.txt678 bytesrainbowarray
#10 2513604-10-responsive-image-defaults.patch0 bytesrainbowarray
#8 interdiff-2513604-6-8.txt2.74 KBrainbowarray
#8 2513604-8-responsive-image-defaults.patch5.69 KBrainbowarray
#6 interdiff-2513604-4-6.txt3.28 KBrainbowarray
#6 2513604-6-responsive-image-defaults.patch3.95 KBrainbowarray
#4 2513604-3-responsive-image-defaults.patch3.25 KBrainbowarray
#1 2513604-1-responsive-image-defaults.patch25.63 KBrainbowarray

Comments

rainbowarray’s picture

StatusFileSize
new25.63 KB

Here is a first patch that adds the default breakpoint group, breakpoint, image styles and responsive image styles.

rainbowarray’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: 2513604-1-responsive-image-defaults.patch, failed testing.

rainbowarray’s picture

Status: Needs work » Needs review
StatusFileSize
new3.25 KB

Had some extra things in the previous patch. This revised version also eliminates one of the image styles. The new styles are named Gigantic and Huge, which just so happens to order the styles from largest to smallest.

Status: Needs review » Needs work

The last submitted patch, 4: 2513604-3-responsive-image-defaults.patch, failed testing.

rainbowarray’s picture

Status: Needs work » Needs review
StatusFileSize
new3.95 KB
new3.28 KB

In theory this should fix the test fails.

There was a capitalization error in one of the image style definitions, and I think the formatting of the breakpoints.yml file was wrong. Also needed to fix a test since there is an additional breakpoint group now.

Status: Needs review » Needs work

The last submitted patch, 6: 2513604-6-responsive-image-defaults.patch, failed testing.

rainbowarray’s picture

Status: Needs work » Needs review
StatusFileSize
new5.69 KB
new2.74 KB

Fixed a couple more bugs in expected UI text and ordering of breakpoint groups by label.

Status: Needs review » Needs work

The last submitted patch, 8: 2513604-8-responsive-image-defaults.patch, failed testing.

rainbowarray’s picture

Status: Needs work » Needs review
StatusFileSize
new0 bytes
new678 bytes

Fixing patch based on error report.

attiks’s picture

+++ b/core/modules/breakpoint/breakpoint.breakpoints.yml
@@ -0,0 +1,7 @@
+breakpoint.all.viewport_sizing:
+  label: Viewport Sizing
+  mediaQuery: ''
+  weight: 0
+  multipliers:
+    - 1x
+  group: All Viewports

this doesn't look right, see http://cgit.drupalcode.org/drupal/tree/core/modules/toolbar/toolbar.brea...

jelle_s’s picture

StatusFileSize
new4.8 KB
new5.95 KB

I moved the new 'Viewport Sizing' breakpoint from the breakpoint module to the responsive_image module because the breakpoint wouldn't make much sense without responsive images. I renamed the group to responsive_image.all because of it. Then I fixed the 'group' property for the breakpoints. Tests should be green.

(BTW: your patch in #10 was empty so I had to reconstruct it using the patch in #8 and the interdiff in #10 ;-) )

rainbowarray’s picture

The trouble with the new name for the breakpoint group, is that it looks very unfriendly in the UI: 'responsive_image.all' vs 'All viewports'

I haven't been able to figure out how to add a human-friendly name for a breakpoint group besides just using that as the name (which does seem to work, even if it's wrong).

Is there any way to do so? There are no schema files for breakpoints.yml files and very little documentation on how they should be written. Would be great to get that into the docs.

attiks’s picture

#13 Valid point regarding the name, we need to figure out a way to fix this

rainbowarray’s picture

Added #2538884: Add labels and weights for breakpoint groups to discuss custom breakpoint group labels (and possibly weights).

rainbowarray’s picture

StatusFileSize
new5.91 KB
new2.07 KB

In light of the fact that we cannot create human-friendly breakpoint group labels, this patch removes the custom group so that the Viewport Sizing breakpoint shows up under the Responsive Image breakpoint group, and Responsive Image shows up as the default breakpoint group. The All Viewports label would have been good, but this is still pretty user-friendly I think.

This patch also updates a test to account for the change in the breakpoint group.

larowlan’s picture

+++ b/core/modules/responsive_image/config/install/responsive_image.styles.narrow.yml
@@ -0,0 +1,24 @@
+uuid: 8eb79e19-da57-4bd3-8304-4e0b5a147276

+++ b/core/modules/responsive_image/config/install/responsive_image.styles.wide.yml
@@ -0,0 +1,26 @@
+uuid: 5cffd3ef-5656-4446-b200-b771d8076568

I recall that we don't include UUIDs in default config

rainbowarray’s picture

@larowlan: The existing image styles in core have uuid's, so I kept those for the new image styles and responsive image styles. Certainly can remove those, just trying to follow the pattern already in core.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good to me and makes it easier for people to use sizes

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: 2513604-16-responsive-image-defaults.patch, failed testing.

jelle_s’s picture

Status: Needs work » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/responsive_image/config/install/responsive_image.styles.narrow.yml
@@ -0,0 +1,24 @@
+    - image.style.large
+    - image.style.medium

+++ b/core/modules/responsive_image/config/install/responsive_image.styles.wide.yml
@@ -0,0 +1,26 @@
+    - image.style.large
+    - image.style.medium

These image styles might not exist. Someone could delete them before installing responsive image. Not sure what to do.

attiks’s picture

We can always provide our own image styles to avoid it?

rainbowarray’s picture

Status: Needs work » Needs review

Here's a patch that adds default image styles within the responsive images module so that the responsive image module is entirely self-sufficient upon installation.

I added more default image styles to fully provide sensible defaults for how responsive images work. It's a lot of image styles, yes, but any site that actually uses responsive images is going to end up with a ton of image styles. So we might as well do this right if we're going to provide defaults.

Also, it should be noted that these responsive styles won't look right in the UI until #2334387: UI changes to support current responsive image standards goes in.

rainbowarray’s picture

StatusFileSize
new12.2 KB
new10.83 KB

Helps if I add the patch.

attiks’s picture

+++ b/core/modules/responsive_image/config/install/image.style.max_1120x1120.yml
@@ -0,0 +1,11 @@
+      upscale: true

+++ b/core/modules/responsive_image/config/install/image.style.max_1720x1720.yml
@@ -0,0 +1,11 @@
+      upscale: true

+++ b/core/modules/responsive_image/config/install/image.style.max_215x215.yml
@@ -0,0 +1,11 @@
+      upscale: true

+++ b/core/modules/responsive_image/config/install/image.style.max_2160x2160.yml
@@ -0,0 +1,11 @@
+      upscale: true

Why the need to upscale? I think it is safer to never upscale.

rainbowarray’s picture

In most cases an image needs to fill a certain amount of space in a layout. Not upscaling means you may get lower-quality images uploaded that break a layout. That's why I also prefer width 100% to max-width 100% for img styles.

attiks’s picture

##2 True, but upscaling means PHP will upscale and lower the image quality, while creating a bigger file, that will get downloaded by the browser.

If we don't upscale a themer can still decide to add width: 100% risking the upscaling effect.

rainbowarray’s picture

StatusFileSize
new12.21 KB
new5.19 KB

Here's a revised patch with upscaling turned off. This keeps these styles consistent with those in the image module. As attiks pointed out, undersized images can still be upscaled in the browser when width: 100% is set.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

Assuming bot will be happy, back to RTBC

rainbowarray’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new7.2 KB
new6.91 KB

Discussed this with webchick. Narrowing down the list of image styles to not overwhelm the user interface. This still provides sensible defaults for the narrow and wide responsive image styles, just with fewer in-between style options.

webchick’s picture

Had a call today with @mdrummond and @Bojhan where this patch came up.

When demoing the patch, Marc showed the list of image styles approximately quadrupling in size, with numerous very similarly-named options (Max 325x325, Max 400x400, Max 600x600, etc. times about 12 or 16).

The problem is:

a) All of those additional image styles selections are going to show up everywhere that image styles are used in configuration: display modes, views, etc., not just encapsulated within responsive image's configuration.
b) There is no clear signal to end users why all of those sizes are predefined. In talking to Marc it's basically:

Narrow: small, medium, large, plus retina for each.
Wide: small, medium, large, plus retina for each.

However, this is very hard to tell from just raw pixel sizes.

c) And even if we were to rename these with more "human-readable" names, the fact is that each individual site needs to decide for itself what form factors/viewport sizes it wants to support. Core currently ships with three image styles: Thumbnail, Medium, and Large with some opinions on what those sizes should be. Many sites override these, and for ~three image styles that's basically fine. But if you have to go in and edit an additional ~12 image styles, each with almost identical names, that will get both very confusing and very irritating very fast.

So Marc and I discussed a compromise which is still providing additional image styles, still naming them "Max XXX" so we don't need to come up with nonsensical English words that happen to flow alphabetically, but limit it to just 4 sizes: 325x325, 600x600, 1300x1300, 2600x2600. This allows for a Narrow/Wide regular/retina, and individual sites can extrapolate from there.

rainbowarray’s picture

One last note that naming the image styles Narrow Small/Medium/Large and Wide Small/Medium/Large is also challenging, because the Narrow responsive image style might need to use some of the image styles with the Wide names, and the Wide responsive image style would need to use some of the image styles with the Narrow names. So a reduced set of image styles with the Max name still works as defaults but hopefully causes less confusion.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

#32 Looks good and agree on the naming

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

So I'm wondering if we can put this all in the standard profile - so if you install in minimal it stays minimal. One thing we need to do if to add an enforced dependency on responsive image module. See the node type provided by the book module for an example. It also needs to go in a new folder in standard config/optional... This should also result in this patch not changing tests. Well, I think that StandardTest should assert the new optional config does not exist until the responsive image module is installed.

attiks’s picture

Assigned: Unassigned » attiks

I'll have a try later today.

attiks’s picture

StatusFileSize
new4.83 KB

If I understand correctly the attached patch is correct, but when I enable the responsive_image module, the optional config isn't loaded, I tried with and without adding the enforced.

PS: If I add responsive_image as a dependency for the standard profile, everything works.

attiks’s picture

Status: Needs work » Needs review
attiks’s picture

According to #2453919: all installed modules' config/optional directories are searched for any configuration entities of the new type

So this doesn't work for profiles?

Status: Needs review » Needs work

The last submitted patch, 38: i2513604-38.patch, failed testing.

attiks’s picture

Status: Needs work » Needs review
StatusFileSize
new5.76 KB

It wasn't working for optional config in install profiles, fixed it

attiks’s picture

StatusFileSize
new7.29 KB
new1.59 KB

Fix added for failing tests

The last submitted patch, 42: i2513604-42.patch, failed testing.

attiks’s picture

StatusFileSize
new8.07 KB
new964 bytes

Tests added to StandardTest to make sure the image styles are not installed by default.

The last submitted patch, 43: i2513604-43.patch, failed testing.

attiks’s picture

StatusFileSize
new8.5 KB
new663 bytes

Tests extended to make sure the optional styles are installed once responsive_image is enabled.

The last submitted patch, 45: i2513604-45.patch, failed testing.

attiks’s picture

Assigned: attiks » alexpott

Back tot Alex to make sure this is good

alexpott’s picture

  1. +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php
    @@ -147,6 +147,8 @@ public function installDefaultConfig($type, $name) {
    +      // Search the install profile's optional configuration too.
    +      $this->installOptionalConfig(NULL, [$type => $name]);
    

    I need to review exactly what this is going to do. And it needs further testing... but the idea of having optional config in install profiles is sound. And perhaps deserves it's own issue.

  2. +++ b/core/profiles/standard/config/optional/responsive_image.styles.narrow.yml
    @@ -0,0 +1,28 @@
    +  module:
    +    - responsive_image
    +  enforced:
    +    module:
    +      - responsive_image
    
    +++ b/core/profiles/standard/config/optional/responsive_image.styles.wide.yml
    @@ -0,0 +1,30 @@
    +  module:
    +    - responsive_image
    +  enforced:
    +    module:
    +      - responsive_image
    

    This is not necessary the dependency is implied from the name of the configuration object.

attiks’s picture

StatusFileSize
new8.33 KB
new442 bytes

1. There's a test added to make sure the optional config gets read, not sure what else I can do. Unless you mean you want to have the tests somewhere else as well, so they don't depend on the install profile and/or responsive_image module.

2. Removed the lines

rainbowarray’s picture

Manually tested this, and I can confirm the image styles and responsive image styles do not show up on the minimal profile after enabling the responsive image module, while they do on the the standard profile.

Standard profile: before enabling responsive image module

Standard profile: after enabling responsive image module

Minimal profile: after enabling responsive image module

rainbowarray’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.38 KB
new8.56 KB

The extra call to installDefaultConfig() doesn't make sense since this means that we have to loop through a lot of stuff twice. We can fix this in a different way. What I mean by tests is that this ability to install default configuration from profiles should be part of the configuration tests not hidden in the StandardTest where it's testing responsive_image.

Status: Needs review » Needs work

The last submitted patch, 54: 2513604.54.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new4.47 KB
new11.98 KB

Ah not so simple - fortunately we have tests... patch adds a test around the new ability of profiles to provide completely new optional configuration.

rainbowarray’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested again. Image styles and responsive image styles added with standard profile, but not minimal profile.

Since tests have been refactored for optional config, moving this back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
@@ -44,7 +44,7 @@ public function testResponsiveImageAdmin() {
     // Add a new responsive image style, our breakpoint set should be selected.

This comment is no longer true. I think we should be a little more specific than "our"

rainbowarray’s picture

Status: Needs work » Needs review
StatusFileSize
new12.23 KB
new912 bytes

Updated test comments as suggested.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

Looking good, thanks all

attiks’s picture

Once committed I'll updated the CR at https://www.drupal.org/node/2453919 or do we need to create a new one for the profile optional config?

alexpott’s picture

Assigned: alexpott » Unassigned

I don't think that the config change needs a CR - it's an addition.

attiks’s picture

#62 Anything else we need to do? Can you commit this, or is it better to ask @webchick?

alexpott’s picture

@attiks I can not commit this - I've worked on it.

webchick’s picture

So I went to commit this, but it's failing on DrupalCI so I queued a re-test an hour and a bit ago and it's still re-queueing. Will check again tonight.

rainbowarray’s picture

I just double-checked the patch, and it still applies against HEAD, but I'm not sure what it means that it's failing on DrupalCI.

attiks’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 59: 2513604-59-responsive-image-defaults.patch, failed testing.

rainbowarray’s picture

Status: Needs work » Needs review
StatusFileSize
new12.32 KB

Here's a fresh reroll. Back to the bottom of the RTBC pile. :<

rainbowarray’s picture

Status: Needs review » Reviewed & tested by the community

Moving this back to RTBC since this was just a reroll.

webchick’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -revisit before release candidate

Oh, crap, I am so sorry! I thought I committed this weeks ago.

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 6c04c93 on 8.0.x
    Issue #2513604 by mdrummond, attiks, alexpott, Jelle_S: Create default...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.