Problem/Motivation

Follow-up to #2534058: [META] Usability of Responsive Image in Core
See point E and F.

Proposed resolution

A- Add a meaningful description to the fallback option.
B- Change option "None" to "None (original image)", just how it is done in #empty_option of ImageFormatter.php

Remaining tasks

- define if "None" should be changed for this Responsive Image form only or all image style list.
- implement patch
- review

User interface changes

None except the listed one.

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dom.’s picture

Two patch attached:
option1: fixes point A, fixes point B locally to Responsive Image style. Nothing else is impacted
option2: fixes point A, fixes point B globally: everytime the image_style_options(TRUE) method is called, the result will be impacted, thus potentially other modules.

Status: Needs review » Needs work
Dom.’s picture

Status: Needs work » Needs review

Noob mistake : forgot review status !

Status: Needs review » Needs work
Dom.’s picture

Status: Needs work » Needs review
cilefen’s picture

Title: Add descriptions when creating a new Response Image Style » Add descriptions when creating a new responsive image style
Issue summary: View changes
RainbowArray’s picture

There is a fallback image description added in #2334387: UI changes to support current responsive image standards.

The none (original image) change is a separate improvement, and that can continue on here.

attiks’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Needs work and needs a test to make sure original image works as expected

attiks’s picture

Status: Needs work » Needs review
FileSize
2.61 KB

Patch rerolled, original added to tests

Status: Needs review » Needs work

The last submitted patch, 11: i2534066_11.patch, failed testing.

The last submitted patch, 11: i2534066_11.patch, failed testing.

attiks’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.9 KB

Description is already added, removed it from the patch

Status: Needs review » Needs work

The last submitted patch, 14: i2534066_14.patch, failed testing.

attiks’s picture

Is breaking on empty string, will need to use a constant

Jelle_S’s picture

The option for the original image can't be an empty string because of the code in ResponsiveImageStyle::isEmptyImageStyleMapping. New patch attached.

Jelle_S’s picture

Title: Add descriptions when creating a new responsive image style » Allow selecting the original image when creating a responsive image style

Status: Needs review » Needs work

The last submitted patch, 17: i2534066-16.patch, failed testing.

The last submitted patch, 17: i2534066-16.patch, failed testing.

Jelle_S’s picture

Status: Needs work » Needs review
FileSize
3.11 KB

Patch with fixed unit test. This patch will still fail because I discovered an other issue while working on this: #2573221: Keyed mapping static cache is not rebuilt when overwriting an existing mapping

Jelle_S’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Also, I just noticed we're unit testing this, but not testing the actual output with a mapping using the original image, so more tests are needed.

The last submitted patch, 21: i2534066-21.patch, failed testing.

The last submitted patch, 21: i2534066-21.patch, failed testing.

Jelle_S’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
6.59 KB

Status: Needs review » Needs work

The last submitted patch, 25: i2534066-25.patch, failed testing.

The last submitted patch, 25: i2534066-25.patch, failed testing.

Status: Needs work » Needs review

attiks queued 25: i2534066-25.patch for re-testing.

attiks’s picture

Small nit picks

  1. +++ b/core/modules/responsive_image/responsive_image.module
    @@ -456,7 +457,12 @@ function responsive_image_get_mime_type($image_style_name, $extension) {
    +  if ($image_style_name == RESPONSIVE_IMAGE_ORIGINAL_IMAGE) {
    

    ===

  2. +++ b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php
    @@ -84,6 +84,7 @@ public function form(array $form, FormStateInterface $form_state) {
    +    $image_styles[RESPONSIVE_IMAGE_ORIGINAL_IMAGE]=  t('- None (original image) -');
    

    $this->t

  3. +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
    @@ -77,7 +77,13 @@ public function testResponsiveImageAdmin() {
    +      [
    +        RESPONSIVE_IMAGE_EMPTY_IMAGE,
    +        RESPONSIVE_IMAGE_ORIGINAL_IMAGE,
    +      ],
    

    1 line is ok

  4. +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
    @@ -85,8 +91,17 @@ public function testResponsiveImageAdmin() {
    +          '//select[@name=:name]//option[@value=:style]',
    +          [
    

    move [ up

  5. +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageAdminUITest.php
    @@ -85,8 +91,17 @@ public function testResponsiveImageAdmin() {
    +          ]
    +        ));
    

    move ] down

Jelle_S’s picture

FileSize
6.57 KB
2.16 KB

New patch addressing #29.

4 & 5: Didn't do that because indentation would be wrong then.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

I'm when when the bot is happy

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 30: i2534066-30.patch, failed testing.

attiks queued 30: i2534066-30.patch for re-testing.

The last submitted patch, 30: i2534066-30.patch, failed testing.

attiks’s picture

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

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

Only thing I wonder is about swapping the ordering so that original image is before empty image, but that could always be a follow-up and/or an improvement in 8.1.

  • webchick committed b332f08 on 8.0.x
    Issue #2534066 by Jelle_S, Dom., attiks: Allow selecting the original...
attiks’s picture

Status: Fixed » Closed (fixed)

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

The last submitted patch, 14: i2534066_14.patch, failed testing.