Currently, all image formatters variants (image style preset, link to content / to image) need to come as a separate formatter type. Contrib formatters (lightbox...) add their own separate versions, and the # of formatters presented in the 'formatter type' select dropdown on 'Manage display' page explodes (often with leg-length names).
When #796658: UI for field formatter settings is looking like it's on its way. When it lands, it can be used to group all those variants into a limited number of formatters, each with the relevant settings.
There might be several ways to organize this, so I propose we give it a little in advance ?
A patch for HEAD2HEAD module will be provided to convert existing image field instances to the new collection of formatters.
| Comment | File | Size | Author |
|---|---|---|---|
| #58 | 812688-image-formatter-d7.patch | 9.12 KB | andypost |
| #47 | 812688-image-formatter-d7_9.patch | 9.12 KB | damien tournoud |
| #45 | 812688-image-formatter-d7.patch | 12.48 KB | andypost |
| #44 | 812688-image-formatter-d7.patch | 12.45 KB | andypost |
| #43 | 812688-image-formatter-d7.patch | 12.14 KB | andypost |
Comments
Comment #1
sunyay!
Comment #2
andypostThis could be really helpful for galleries!
Comment #3
manuel garcia commentedNow that I'm familiar with this, let's see if i can do something of value here.
Comment #4
yched commentedSo one obvious proposal is "one formatter, two settings" :
- image style (dropdown select) : original, + all image styles
- link (checkboxes - or dropdown select ?) : no link, linked to content, linked to file
Pros :
sets good practice for contrib formatters ('put image style as a setting rather than as separate formatters' - see http://drupal.org/project/hover_preview for why this sucked in D6)
Cons :
more clicks to change the image style used in a given view mode (before : just select a different formatter; after : click 'edit settings', select a different image style, click "Submit')
I think the pros outweight the cons, though. Keeping the image styles in separate formatters only "scales" (so to speak...) for the one 'formatter family' that happens to be defined in defined in core.
Comment #5
andypostLet's see how many tests are broken
Comment #7
andypostFixed
- tests
- image_image_style_save() update formatter settings when preset name changed
PS: do not forget to change #606598: Human readable image-style names
Comment #8
joachim commented> sets good practice for contrib formatters ('put image style as a setting rather than as separate formatters' - see http://drupal.org/project/hover_preview for why this sucked in D6)
This raises the question... can a contrib module such as hover_preview use hook_form_alter to add settings to an existing formatter, or does it have to define a new formatter for itself?
Comment #9
andypostjoachim, I think much easy to implement own formatter with own settings oppose altering
Comment #10
sunIn D6, modules like hover_preview, lightbox2, thickbox, colorbox, and countless of others cloned all the image styles, using a identifying prefix or suffix for their special action.
In D7, with this patch, I could see two different ways of extensions:
1) Add a new "Lightbox2" formatter, providing image style select list like core's "Image" formatter, plus any additionally needed settings. (yay, AWESOME, additional settings!!! :)
2) Enhance core's "Image" formatter with an optional #states-driven checkbox, which may or may not expose an entire fieldset of additional settings. Use the theme system to squeeze a preprocess function in front of the normal processing (if that's sufficient), or entirely replacing the original preprocess/theme functions with wrappers/custom versions.
Now, you will tell: Technically, 1) is correct and good.
I'll agree, but have to amend: Usability-wise, it's still formatted as "Image", stuff like a lightbox or preview are only attached later to it, so 2) makes more sense from a user perspective.
--
This patch looks ready to fly for me. Not sure whether the functionality is covered by tests though.
Comment #11
yched commented@joachim : that's a good question. Right now, we have no tools in place for easy altering of existing formatters. Main missing thing is a hook to alter the render array returned by a formatter. problematic, because such a hook would be called once per rendered field, which is potentially 100s of times on listing pages, and this raises performance issues.
I'm not sure we will solve that in D7. Having usable formatter settings is a nice 1st step :-)
As joachim says, implementing a new formatter is not a complex task anyway. Altering render arrays starts to be tricky when there are several contrib modules that want to alter the same formatter. The render arrays returned by formatters are typically small and simple, the chances of stepping on each other's toes are real.
Thanks for tackling this, joachim ! Code review :
My 1st reaction is 'the isset and the conditional are not needed ($settings['foo'] is always set at least to the default value, '' in both cases). Then I figured this can apply when an image style is deleted. I'd suggest adding a comment about that for the 1st line, and simplifying the 2nd line to just $link_types[$settings['image_link']].
Then again : image_image_style_save() has code to take care of image styles renaming. Similarly, the case of image style deletion should be taken care of in
image's hook_image_style_delete(). That's a separate issue though.
Maybe keep the summary simple and only mention the link setting if it's one of 'to content / to file' ?
I know core only has 1 formatter for images with this patch, which will be assigned by default, but I'd suggest keeping an explicit line setting the formatter ['type'], just for later safety.
Also : shouldn't we fix the definition of the field_image field instance created in the default install profile ?
Powered by Dreditor.
Comment #12
yched commentedre sun #10: "Usability-wise, it's still formatted as "Image", stuff like a lightbox or preview are only attached later to it, so 2) makes more sense from a user perspective."
This will lead to all being stuffed into the same and single 'image' formatter, which is not great UX wise. When I add a new formatter module, I prefer seeing new formatters available rather than having to open settings for existing formatters to discover where is the new candy.
Comment #13
manuel garcia commentedI might be repeating what you already agree on, but well this is my take on it, not sure I understand every part of the discussion above... I think it makes sense to move some options to the settings UI let's say from:
To:
, and then in the options choose the visible image style, and the style to link to.
Usability-wise this approach for these kinds of cases does involve an extra step wish is bad. However it un-clutters the options the user sees which is good. We could tackle the first problem by opening up the options for the formatter that the user selects automatically for them when needed.
What do you think?
Comment #14
andypostTagged.
- fixed standard.profile
- added comments about isset()
- fixed test settings
By default every image field is set to full-image-without-link - this could be changed in install profile and possibly in field defaults. Next image_image_style_delete() already cares about replacement of new style.
isset($image_styles[$settings['image_style']])cares about image styles that introduced in code and have no reaction on module_enable/disable. Same for link - contrib could insert own values in this setting.Comment #15
andypostAttached screenshots. Suppose we could remove
Style: ... Link: ...if commited #606598: Human readable image-style namesSo only style label and link type would be displayed
PS: same could be done for #857314: Add form for number formatter settings
Comment #16
sunIn the edit form, we could remove the "Image" prefix for both settings? i.e., just have "Style" and "Link"?
Second, the label "Link" currently has a select list showing "Image linked to file". So what? :) I guess that the Link can be either "<none>", "File", "Content". In other words: Could we drop "Image linked to" ?
Comment #17
andypostI make "Image style" and "Image link" to make it easy to translate because this adds a "context" meaning to option.
About options in "link" - I'm not so good in English but I think combination of "title" and "option value" should contain some verb:
Link to "file"
or Links to "content"
So I glad to see more reviews about stings, because we should care about how this could be translated.
Comment #18
tstoecklerActually the context argument is invalid, because we have proper string contexts in D7 which we could pass to the strings.
We should try to find the most adequate and correct English strings.
Comment #19
andypost+1, Exactly what I wanna say
About t()'s context, this is sad that core use this only for long month names.
It scares to update most of core's strings to context. But it shell be done someday...
Comment #20
sunStray space after implode.
@all / yched: We discussed elsewhere that it would probably be a good idea to let these formatter summary callbacks return an structured array containing labels and values, so as to allow contributed modules to implement better or alternate UIs, display this info elsewhere, alter the summaries, etc. Anyone up for tackling this in a new issue?
Please remove the "Helper function:" prefix.
46 critical left. Go review some!
Comment #21
andypostUpdated patch with #20
Also link information displays only if image really linked.
Comment #22
andypostWas wrong! So new patch and screenshots. If 'No link' chosen then no summary for link
Comment #24
joachim commented> This will lead to all being stuffed into the same and single 'image' formatter, which is not great UX wise. When I add a new formatter module, I prefer seeing new formatters available rather than having to open settings for existing formatters to discover where is the new candy.
I think it depends on the formatters.
Say you had a module that wanted to add an option for the hover on an image, or (made up example) the border style.
Would you want a whole new formatter which would duplicate imagecache and lightbox settings, or to get an extra dropdown in the existing formatter? I'd say for usability, the latter.
Comment #25
andypostPrevious patch mixed with hunk from #278425: Using basename() is not locale safe
Comment #26
moshe weitzman commentedLets try not to focus on this edge case. Better is to craft the user experience assuming that there is just one "system" and we design the best user experience for it. Consider that many sites will be running distributions and downloading Features which have all these modules pre-configured and ready to go. Thats where we are headed. It might take a bit, but we should keep the goal in mind. The days of downloading individual modules that provide small formatters are waning.
Comment #27
andypostwhen new module added it's formatter gets available in dropdown and you could optionally configure if defaults does not conform your needs.
Comment #28
yched commentedI agree with 'Image style' rather than just 'Style', because the former refer to a officially known animal in core, while the latter doesn't.
But I vote on 'Link' rather that 'Image linked to' for the link option.
In short, I vote for :
In settings form
Image style:
Original
style_1
style_2
Link:
< none >
to content (if accepted, rather uncapitalized ?)
to file
In summary:
Image style : style_x | Original image
Linked to file | Linked to content | (no 2nd line if no link)
Comment #29
andypostI think core should introduce a Pattern for formatter settings/summary. There was no pros&cons about.
So let's decide:
1) a way to display settings form - small, understandable titles for elements with/without description
2) a way to display summary
Image settings:
Image style: [select] (no descr)
Link: [select] (no descr)
Image summary:
Image style: style_x | Original image
Linked to file | Linked to content | (no 2nd line if no link) - no title for tis option
Text settings: (#504564: Make summary length behave with fields)
Trim length: [text input]
Text summary:
Trim length: number
Number settings: (#857314: Add form for number formatter settings)
Thousand marker: [select]
Decimal marker: [select]
Scale: [select]
[checkbox] Display with prefix and suffix.
Number summary:
Preview: 1 234.567
Display with prefix and suffix. | (no 2nd line if no setting)
Comment #30
yched commented#29 looks good to me - what do others think ?
Comment #31
tstoecklerYes, #29 makes sense.
Comment #32
andypostChanges
- removed functions for options, using core's image_style_options()
- Settings form
1) Image style option starts with , seems more reasonable because if no style then we get 'Original image' in summary
2) Image link option starts with and summary displays only if link to assigned
Comment #33
yched commentedI don't think 'Image style :
<none>' in form makes it clear that it means 'original image'.I thought we agreed on 'Link' instead of 'Image link' in the form label ?
Comment #34
andypostChanged to 'None (display original image)'
Fixed "Link"
Comment #35
manuel garcia commentedFrom an end user perspective, knowing that you won't be using any image style is not relevant. I think just using 'Original image' would make more immediate sense.
Comment #36
sunAgreed, "original" is a perfectly valid image style and would be sufficient. The only thing we need to prevent is having 2x "original" in the image style select options, from which one is a custom image style that happens to be named "original".
Either we prevent creating an image style called "original" or we add a prefix/suffix to the real one, i.e., <original> or similar.
Comment #37
yched commentedI think #36 in fact makes a point for #34's 'None (display original image)' :-)
Or maybe without the verb, which doesn't seem to belong in the list : 'None (original image)'
I still don't get this. In this patch, $link_types is a fixed array, so the comment about contrib makes no sense. The real reason for the check is "Display this setting only if image is linked", and thus the check should rather be
if (!empty($settings['image_link'])):It's possible that $link_types could / should be made extensible, but that's outside the scope of this patch.
38 critical left. Go review some!
Comment #38
andypostRe-roll with 'None (original image)'
About naming - I still hope to see #606598: Human readable image-style names commited and then list of styles became more user-friendly
Because the select named as "Image style" so using 'None (original image)' makes more sense to me. Because this actually means "I don't need styles, just display original" - this is a widely used for search indexing and rss
@yched we should use isset() on fixed array and comment about contrib because nothing stops contrib from
I think we could make this extensible but this looks like over-engineering for this case and anyway out of scope of this patch
Comment #39
yched commentedThere is no valid reason for contrib to put an invalid value in $instance['display']['default']['settings']['image_link']. Stating that we take care of these sounds like babysitting broken code.
Middle ground : agreed that it's a better code practice to check that $link_types[$settings['image_link']] is set before using it, but let's drop the comment about contrib (which currently looks broken english anyway) :
Comment #40
andypostSure, isset() just checks that setting in defined array to display only allowed values
Comment #41
yched commentedThanks !
Comment #42
manuel garcia commentedGood point on #38 about using 'None (original image)', makes sense!
Comment #43
andypostI think while we on it we should add a limit setting to limit a number of images to display for current view mode.
Suppose this feature would be very useful.
Also added a test for this setting.
New screenshot attached
Comment #44
andypostA bit usability - limit list to actual field cardinality
Comment #45
andypostWrapped array with default formatter settings
Comment #46
damien tournoud commented-1 for adding this new "limit the number of images to be displayed" feature. This is really not the way to do it.
Comment #47
damien tournoud commentedReposting #40 that is RTBC.
Comment #48
andypostThis issue is a task for refactoring of image formatter so "limiter" should be discussed.
It is not API change, also test applied.
So let's get more reviews on #45 and #47. While this not commited I see no reason to open new issue with feature request.
Comment #49
damien tournoud commentedPlease open an separate issue for the feature request. This refactoring *task* is clearly not the place to discuss it.
Comment #50
yched commentedAgreed with Damien - A way to limit to 1st n values would be cool, but belongs in a different issue.
Typically, that would be a feature that would benefit *any* formatter for any field type, not just the one single 'image' formatter for image fields.
Comment #51
dries commentedPersonally, I find the UI to be weak.
- What does: "Format settings: Image" (see http://drupal.org/files/issues/image_field-d7.png) mean?
- The "Link - to content" approach is awkward too. We never split up sentences like that.
I think we'd like to do some UX work on this.
Comment #52
andypostTagging for UX team suggestions.
Comment #53
tstoecklerI think "Format settings: Image" becomes clear from the context. First of all people will know the idea of a formatter from other fields. Also, before they get to this screen, they see "Image" in the Formatter column, so "Format settings" should make sense for them when they're editing, well, the settings.
Comment #54
yched commented'Link' dropdown selector - then I see no other way than repeating the word :
Link
-
<none>- Link to content
- Link to file
Comment #55
andypostIs there any ideas how to continue this issue?
Comment #56
yoroy commentedSubscribe, will review.
Comment #57
yoroy commented"Format settings: Image" is the static text replacement for the choice you make in the previous screen:


It helps maintain context:
Maybe it helps if it said "format settings *for*: image" instead?
For the Link select:
- Capitalize the options
- Make the label a bit more descriptive. We want to fix this in the label, not in the options by adding redundant wording that makes them harder to scan.
- I don't see the problem with labels that trigger you to complete a sentence, on the contrary, it is a construct that helps you connect the dots and avoid redundant wording. Which is important here because there's little room to work with.
Suggestion: "Link image to". It's quite descriptive and puts the main trigger word first.
Comment #58
andypostre-roll with proposed
Comment #59
sunFrom a technical perspective, this patch was RTBC already. So I suggest and ask the UX team to RTBC this patch once they are happy with it, please.
Comment #60
yched commentedI guess the issue with 'sentences' that start as Label and end in the select options is that they have poor translatability. You cannot ensure that the order stays the same in any random language.
Hence my proposal in #54.
Comment #61
damien tournoud commentedTotally true, but those are very elegant and quite easy to get right.
Example from content_handler_field_multiple.inc in CCK6:
Comment #62
damien tournoud commentedFor stuff which is technically a prefix only, like the "Link image to" label, it is always possible to make a convoluted translation, even in languages where this prefix would be more natural as a suffix.
Comment #63
andypostOTOH 'to content' and 'to file' could confuse because without context it looks like verb
Comment #64
joachim commentedComment #65
yched commentedre #61: right, I totally forgot I did that in CCK. I like it :-p. However, we were replacing an easy-to-spot word in the middle of a sentence by a form element. Not sure how this would apply here.
re #64 : "Image link target : " sounds convoluted and misleading (literally it means 'link without a target', not 'no link'). Besides, 'target' is something else when it come to links /
<a>tags.I still stand by #54.
Comment #66
Bojhan commentedsubscribe
Comment #67
Bojhan commented/me thinks @yched is totally over-thinking this label issue.
Link image to? Why wouldn't that work? I mean translation can easily go for something diffrent, no reason for them not to change the order when appropriate.
Comment #68
yched commented@Bojhan : fine.
Other than translatability :
- Are you OK with the fact that the UI for the two settings aren't grammatically homogenous ("Image style : style_name" / "Link image to : Content") ?
- Are you OK with "Link image to : " ?
If so, #58 is ready. If not, #54 addresses both concerns.
Anyway, tired of bikeshedding back and forth here. Setting to #58 RTBC.
Comment #69
Bojhan commented@yched I think that should be fine, I mean grammatical homogeneously might be a discussion point as I agree that isn't the "best" thing. But repeating the word is only adding more load, so - yup lets move this in. I would really love to test this someday
Comment #70
yched commentedOops, input format typo
#68 was supposed to read :
Are you OK with "Link image to :
<none>" ?Comment #71
Bojhan commented@yched yes like in #57. I am ok with that.
Comment #72
dries commentedI decided to commit #58 but more than happy to follow-up with language tweaks and smaller UX changes.
Comment #73
andypostIs there any proposals from UX and any tweaks?