Problem/Motivation

When people understand that image styles control the size of their images, but want to change the defaults or create a new style, they return to the field display settings, and don't think to look under configuration. We experienced this problem in the Google Usability Study: (participant 8a)

Proposed resolution

Add a link near image styles drop-down in field display settings to the image style configuration area.

CommentFileSizeAuthor
#76 1433796-76.patch7.73 KBrpayanm
#76 1433796-interdiff.txt3.27 KBrpayanm
#73 interdiff-1433796-71-73.txt614 byteshampercm
#73 link_to_image_styles-1433796-73.patch7.29 KBhampercm
#71 interdiff-1433796-69-71.txt1.72 KBhampercm
#71 link_to_image_styles-1433796-71.patch7.17 KBhampercm
#69 interdiff-1433796-60-69.txt2.56 KBhampercm
#69 link_to_image_styles-1433796-69.patch6.44 KBhampercm
#63 1433796-image-styles-link-position-floated.png29.93 KByoroy
#63 1433796-image-styles-link-position.png30.58 KByoroy
#60 rerollof53-1433796-60.patch5.43 KBhampercm
#53 interdiff-1433796-53.txt1.97 KBundertext
#53 link_to_images_styles-1433796-53.patch5.41 KBundertext
#48 interdiff.txt2.78 KBclaudiu.cristea
#48 link_to_images_styles-1433796-48.patch3.44 KBclaudiu.cristea
#45 link_to_images_styles-1433796-45.patch3.35 KBundertext
#42 link_to_images_styles-1433796-42.patch3.09 KBclaudiu.cristea
#42 interdiff.txt993 bytesclaudiu.cristea
#38 interdiff.txt2.99 KBclaudiu.cristea
#38 add_a_link_to-1433796-38.patch3 KBclaudiu.cristea
#35 interdiff-1433796-35.txt902 bytesjoshi.rohit100
#35 1433796-configure-image-styles-35.patch695 bytesjoshi.rohit100
#32 1433796-configure-image-styles-32.patch1.05 KBjoshi.rohit100
#30 interdiff-1433796-30.txt614 bytesjoshi.rohit100
#30 1433796-configure-image-styles-30.patch671 bytesjoshi.rohit100
#28 add_a_link_to-1433796-27.png78.59 KBopratr
#26 1433796-configure-image-styles-12.patch733 bytesgitesh.koli
#23 1433796-configure-image-styles-12.patch725 bytesgitesh.koli
#22 1433796-configure-image-styles-11.patch725 bytesgitesh.koli
#18 1433796-configure-image-styles-11.patch757 bytesgitesh.koli
#15 1433796-configure-image-styles-10.patch962 bytesnmudgal
#11 1433796-manage-image-styles-10.patch765 bytesjaffaralia
#5 1433796-manage-image-styles-2.patch798 byteswebbykat
#2 1433796-manage-image-styles.patch800 byteslarowlan
#2 Selection_019.jpeg42.62 KBlarowlan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Issue tags: +Novice
larowlan’s picture

Status: Active » Needs review
FileSize
42.62 KB
800 bytes

Patch adds link to formatter settings form.
Note this introduces a new string so can't be backported.
The existing string is 'Image styles' so I don't think that provides enough context. Happy to swap it out for something existing if it can be found.

larowlan’s picture

Issue tags: +GoogleUX2012
webbykat’s picture

That patch worked beautifully for me, minus a Git warning: "1 line adds whitespace errors" (looks like line 9).

webbykat’s picture

Updated patch without the whitespace that was causing the error.

SuperHeron’s picture

That patch seems OK. However, when I want to go back to field display settings page, I have to click twice on the "Back" button of my browser. Clicking once should be enough.

yurtboy’s picture

Would that be an Overlay issue?
I tested the patch and SuperHeron's comments on the click back and it is confusing but not sure if this patch can "fix" that?
Plus isn't the back button suppose to go away? ( -:

Dragan Eror’s picture

Status: Needs review » Reviewed & tested by the community

Patch from #5 works perfectly.
"Go back" button also works if Overlay is disabled.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+  $item = menu_get_item('admin/config/media/image-styles');
+  if ($item['access']) {

What's wrong with user_access()? Also for altering it's generally better to assign #access to the form element rather than conditionally defining it.

yoroy’s picture

Nice patch! I think we don't use the 'manage' word that much, probably more consistent to say 'Configure image styles'.

jaffaralia’s picture

Status: Needs work » Needs review
FileSize
765 bytes

i changed the word manage to configure as mentioned in 10

The last submitted patch, 1433796-manage-image-styles-10.patch, failed testing.

jaffaralia’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +Usability, +Novice, +GoogleUX2012

The last submitted patch, 1433796-manage-image-styles-10.patch, failed testing.

nmudgal’s picture

Status: Needs work » Needs review
FileSize
962 bytes

Please find the attached patch as per comment #9 and #10.

Thanks.

claudiu.cristea’s picture

Issue tags: -Usability, -Novice, -GoogleUX2012
gitesh.koli’s picture

Issue summary: View changes

I am going to try to rework this patch for the latest version of d8.

gitesh.koli’s picture

Status: Needs review » Needs work

The last submitted patch, 18: 1433796-configure-image-styles-11.patch, failed testing.

gitesh.koli’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 18: 1433796-configure-image-styles-11.patch, failed testing.

gitesh.koli’s picture

FileSize
725 bytes
gitesh.koli’s picture

FileSize
725 bytes
gitesh.koli’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: 1433796-configure-image-styles-12.patch, failed testing.

gitesh.koli’s picture

Status: Needs work » Needs review
FileSize
733 bytes
jfrederick’s picture

FileSize
2.97 KB

I changed the capitalization of the link while also translating it. Also, converted it to use dependency injection. All of this during the Austin sprint.

opratr’s picture

Assigned: Unassigned » opratr
Status: Needs review » Reviewed & tested by the community
FileSize
78.59 KB

Patch looks like it works. Link is where it's expected an takes user to expected destination. Screen shot attached.
Changed status to RTBC

opratr’s picture

Status: Reviewed & tested by the community » Needs review

Got out of sync with #27. Will review again.

joshi.rohit100’s picture

Updated as Drupal 8 Apis changed.
Please review now.

claudiu.cristea’s picture

Status: Needs review » Needs work
    Thank you.
  1. +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
    @@ -56,7 +56,9 @@ public function settingsForm(array $form, array &$form_state) {
    +    $element['configure_styles'] = array(
    +      '#markup' => \Drupal::l($this->t('Configure Image Styles'), 'image.style_list'),
    +    );
    

    Don't you think that this needs to go just below the "Image style" select as it's referring to that element?

  2. +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
    @@ -56,7 +56,9 @@ public function settingsForm(array $form, array &$form_state) {
         return $element;
    

    Please add an empty line before return statement. Also between each form element as is now.

joshi.rohit100’s picture

Status: Needs work » Needs review
FileSize
1.05 KB

updated patch as #31. Please review now.

claudiu.cristea’s picture

Status: Needs review » Needs work

Thank you.

  1. +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
    @@ -44,11 +44,16 @@ public function settingsForm(array $form, array &$form_state) {
    +    ¶
    ...
    +    ¶
    
    @@ -56,7 +61,7 @@ public function settingsForm(array $form, array &$form_state) {
    +    ¶
    

    Trailing spaces at the end of lines. Remove them.

  2. +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
    @@ -44,11 +44,16 @@ public function settingsForm(array $form, array &$form_state) {
         $link_types = array(
           'content' => t('Content'),
           'file' => t('File'),
         );
    

    There's no need for empty line here while $link_types is together with the next element.

Also please publish every time an interdiff, otherwise is hard to track changes.

The last submitted patch, 32: 1433796-configure-image-styles-32.patch, failed testing.

joshi.rohit100’s picture

Status: Needs work » Needs review
FileSize
695 bytes
902 bytes

Updated patch as #33

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Good to go for me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We seem to have lost the dependency injection fro #27 why?

Also shouldn't we only be adding the link if the user has the administer image styles permission?

claudiu.cristea’s picture

Status: Needs work » Needs review
FileSize
3 KB
2.99 KB

Added back the dependency injection but cleaned up and re-adapted the constructor signature.

claudiu.cristea’s picture

Title: Add a link to admin/config/media/image-styles near image style optons in field display settings area » Link to images styles from image field display
Assigned: opratr » Unassigned
claudiu.cristea’s picture

Title: Link to images styles from image field display » Link to images styles from image field display settings
fietserwin’s picture

Status: Needs review » Needs work

I agree with #37, 2nd remark: add an #access property to the form item.

And a small doc error:

+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
@@ -20,7 +24,55 @@
+   * Constructs a FormatterBase object.
+   *

Constructs an ImageFormatter object.

claudiu.cristea’s picture

Status: Needs work » Needs review
FileSize
993 bytes
3.09 KB

Ah, I missed that from #37.

fietserwin’s picture

I'm fine with the patch now. However, I see that e.g. CommentForm (core\modules\comment\src\CommentForm.php) injects the current user (whereas NodeForm (core\modules\node\src\NodeForm.php) does not. As we tend to use injection in OO code and try to reserve Drupal:: for procedural code only, I think it would be just a bit better to inject the current user here as well.

What do you think?

claudiu.cristea’s picture

Status: Needs review » Needs work

Ha, ha :) I only checked NodeForm and decided to go in that way. But I agree that injection is better.

Will rework the patch.

undertext’s picture

Status: Needs work » Needs review
FileSize
3.35 KB
fietserwin’s picture

Status: Needs review » Needs work

Complete the documentation for the constructor by adding:

   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user account.

After that the patch is OK.

(Note: PhpStorm warns you for these omissions, you may apply for a free license for open source development)

claudiu.cristea’s picture

And please add an interdiff.txt against #42.

claudiu.cristea’s picture

Status: Needs work » Needs review
FileSize
3.44 KB
2.78 KB
claudiu.cristea’s picture

claudiu.cristea’s picture

fietserwin’s picture

Status: Needs review » Reviewed & tested by the community

Besides reviewing, I also tested locally that the access check indeed works: RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We should be testing this - otherwise we could potentially break this.

undertext’s picture

Status: Needs work » Needs review
FileSize
5.41 KB
1.97 KB

Trying to cover this in tests.

fietserwin’s picture

Thanks for adding a test. A few questions arise though:
- Should we use assertLink(), assertLinkByHref() (my preference) or both?
- Should we test the negative case of the #access part (I think so)?

Leaving to NR to get more opinions on this, but feel free to make a new patch conforming to your (or mine) view on this.

m1r1k’s picture

Issue tags: +#ams2014contest

Status: Needs review » Needs work

The last submitted patch, 53: link_to_images_styles-1433796-53.patch, failed testing.

eporama’s picture

Assigned: Unassigned » eporama
Issue tags: -

Taking at look at this at NERDSummit2014

hampercm’s picture

Assigned: eporama » hampercm

Taking over from eporama

hampercm’s picture

Status: Needs work » Needs review
FileSize
5.43 KB

Rerolled patch from #53 against 8.0.x

fietserwin’s picture

My remarks from #54 are still standing. with those 2 changes I will RTBC.

hampercm’s picture

Assigned: hampercm » Unassigned
yoroy’s picture

Status: Needs review » Needs work
FileSize
30.58 KB
29.93 KB

I still very much like this patch. Adding a fresh screengrab, the one in #48 shows it in a different place than it is now:

screengrab of patch in #60

I think it would be even better if we put the link next to the select list. It makes this link slightly less prominent by taking it out of it's own line, removing it from the top to bottom flow. Slightly less prominent is good here because you won't need this link most of the time. It's not the same as the link for editing the machine name of things, but ginving this link the same amount of prominence here seems right:

screengrab with link to the right of the image style select list

Can somebody reply to the questions in #54?

fietserwin’s picture

#63: Good idea, seems like a nice improvement to me.
- Perhaps with brackets around, or is that not international enough, i.e. do brackets have to be translated and is that worth the hassle?
- If it is done in css, assure that RTL languages keep working.
- Open in new tab or do we never do that? I'm normally opposed to this as the user can force this him/herself, but in this case the user may loose (a lot of) changes by (unintentionally) clicking on this link. OTOH, any new styles won't show when returning to this tab.

yoroy’s picture

- I don't the brackets are necessary here, I think they were added to the machine name pattern to illustrate that this value is a "synonym" for the value in the text field before it.
- yup
- We never force a link to open in a new tab, but you bring up an important point. That any new image styles won't show up is enough reason to not open in a new tab, but we should also prevent losing unsaved changes. AFAIK that risk is already there (you'll lose changes to individual field settings if you don't save on the whole content type) and I think there's already an issue open about that. Maybe this is a case where you'd want the image styles ui to show up in a modal window, but then still only if a new image style will become available once you exit that modal. Hmmm.

Bojhan’s picture

I am not sure if we should worry about it too much. Unlike other settings, clicking away here - although destructive is only a minor inconvenience. As its likely 3/4 settings.

Ideally we have some form of localstorage here, just like we do with views. But realistically we can probably just get away with the fact that people lose data, since its relatively easy to recover. I am not sure if it makes much sense to introduce a one-off pattern, for that inconvenience.

yoroy’s picture

Thanks, that sounds like the right trade off to me as well.

fietserwin’s picture

I agree, as well, I just wanted to raise the options. So, a new patch should add #63 and #54 and it's OK.

hampercm’s picture

Status: Needs work » Needs review
FileSize
6.44 KB
2.56 KB

The patch from #60 was causing a PHP error when I browsed to /admin/structure/types/manage/article/display: it looks like the second parameter of LinkGeneratorInterface::generate() had been changed from a string to a URL type since then. I fixed that and also modified the first parameter based on the recommendation for translatable text given in LinkGeneratorInterface::generate()'s documentation.

I've incorporated the recommendations from #54 as follows:
- Changed the assertLink() test to use assertLinkByHref() instead
- Added a test to check that the link isn't present if the user lacks 'administer image styles' permission

I'm not sure if the code I added for the additional test is the cleanest way of doing it, so if you have feedback on that I'd appreciate it.

I wasn't sure how to cleanly implement the recommendation from #63 to move the link to the right side of the UI, so that is not done yet.

fietserwin’s picture

Thanks for updating the patch.

Implementing #63 does not seem so straightforward as there is inline text before the element, so just playing with display and/or float did not give me the desired results. To implement #63, we could add the link as the #description of the select element. this will place the link within the form element wrapper:

if ($this->currentUser->hasPermission('administer image styles')) {
  $element['image_style']['#description'] = $this->linkGenerator->generate($this->t('Configure Image Styles', array('@url' => \Drupal::url('image.style_list'))), \Drupal\Core\Url::fromRoute('image.style_list'));
}

From there on, we need to make this description inline-block and give it some space before (I guess that putting a space in the :before will work for both LTR and RTL, whereas a margin-left will only work for LTR). so we need to add some css to it.

Rest of the patch is RTBC, thus if we don't consider #63 worth the hassle, the whole patch is RTBC for me.

hampercm’s picture

Putting the link into #description was a big help; thanks @fietserwin!

The link now appears to the side of the main UI flow, as per #63. I implemented RTL support based on how I've seen it done elsewhere in D8, using media queries.

fietserwin’s picture

Status: Needs review » Needs work

To have the description wrap on very small screens, I arrived at this css. it also includes my idea for RTL support, feel free to pick your preferred method, but I think that overruling the nowrap should be added:

#field-display-overview .form-item-fields-field-image-settings-edit-form-settings-image-style {
  white-space: normal;
}
#field-display-overview .form-item-fields-field-image-settings-edit-form-settings-image-style .description {
  display: inline-block;
}
#field-display-overview .form-item-fields-field-image-settings-edit-form-settings-image-style .description:before {
  content: "\00a0";
}

Note: \00a0 is the Unicode code for a nonbreakable space, as   does not work in content, see e.g. http://stackoverflow.com/questions/16552397/css-how-to-add-white-space-before-elements-content.

hampercm’s picture

Status: Needs work » Needs review
FileSize
7.29 KB
614 bytes

I added the CSS to override nowrap. I've left the implementation of RTL support as-is for consistency with other D8 CSS, though I do think your suggested way of doing it is pretty slick :)

fietserwin’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, everything looks good now.

I was surprised by the possibilities of the #description tag you used (not a simple string, but a render array). It is not documented on the Form API page, but it works. However, the description div gets rendered but remains empty, only the content (the render array) is not rendered. And the aria-describedby attribute on the select element thus refers to an empty element or to the link.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
@@ -44,8 +108,11 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
+        '#markup' => $this->linkGenerator->generate($this->t('Configure Image Styles', array('@url' => \Drupal::url('image.style_list'))), \Drupal\Core\Url::fromRoute('image.style_list')),

We should be injecting the url_generator here instead of using \Drupal::url()

rpayanm’s picture

Status: Needs work » Needs review
FileSize
3.27 KB
7.73 KB
fietserwin’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for picking this up. I think that this addresses the concern of #75.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a prioritized change (usability) as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. Committed 3741a5e and pushed to 8.0.x. Thanks!

  • alexpott committed 3741a5e on 8.0.x
    Issue #1433796 by hampercm, claudiu.cristea, joshi.rohit100, gitesh.koli...

Status: Fixed » Closed (fixed)

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