The dubious amount of field formatters for Lightbox2 had been bugging me for quite some while.
I'm talking about the multitude of "lightbox/lightshow__image style__lightbox style" style formatters.
Imagine having 10 image styles (that's not so far fetched, I think). That will lead to no less than a hundred formatters in the display list!
I propose these obviously config level settings to be handled by not additional formatters, but the field_formatter_settings_form hook (as such settings should be).
I've implemented such a single formatter with the ability to configure the following settings per field instance:
- Lightbox type: lightshow or single lightbox.
- Image style: a select list of image styles. What to display as a thumbnail.
- Lightbox style: a select list of image styles. What to display inside the lightbox itself.
- Caption field: a list of image entity fields to choose which field to display as a caption (this one could be later replaced by some more refined display type, e.g. an added 'lightbox' display mode for image file types, etc.).
I've attached a patch including these features, hope it can be ported a.s.a.p.
Comments
Comment #1
Karsa CreditAttribution: Karsa commentedI fixed a very minor bug in the settings form (double array enveloped options, LOL).
I also attached some screenshots of how the feature works.
Note how where there previously were dozens of formatters, there is now only a single one.
I believe configuring a lightbox2 display with this newly added settings form is much more instinctive to use.
I need feedback on this!
Comment #2
futurist CreditAttribution: futurist commentedGreat improvement, thank you.
However, the patch didn't apply properly (against 7.x-1.0-beta1):
Comment #3
Karsa CreditAttribution: Karsa commentedStrange, I think this is because of CRLF vs. plain LF newlines, it's stupid that git doesn't support that.
I attached a plain LF diff file, it works fine for me on 7.x-1.0-beta1.
(Sorry for being gone so long :) ).
Comment #4
Karsa CreditAttribution: Karsa commentedComment #5
yukare CreditAttribution: yukare commentedThis is a good improviment, i too do not like the way it is now. I will try the path and make some tests if it do not affect anything else I will commit it.
Comment #6
yukare CreditAttribution: yukare commentedCan you explain to me what this does and when it is used? Because when we set the image field to use lightbox, it chooses hidden for caption, there is not a default or unset value. If this is the default caption by drupal we must then add a new option to caption field to let the user choose it.
When we resolve this simple question, the path will be commited.
Comment #7
yukare CreditAttribution: yukare commentedCommited the path to git: http://drupalcode.org/project/lightbox2.git/commit/aa5ddcc
Thanks by your work on this Karsa, but can we work on question in #6? With this path commited i can now work on another important issue for me(grouping).
If you will work on any change about this, please get the version on git and create a new path.
Comment #8
Karsa CreditAttribution: Karsa commentedThat branch of the switch handles formatting CCK fields as the caption.
As I said, it probably would be preferable to add these options to the caption display instead of every field as an option:
I shall try to code this ASAP.
Comment #9
Karsa CreditAttribution: Karsa commentedOK, coded it, this patch adds the functionality of adding a rendered entity as the caption of the lightbox.
You can now select the caption type as: hidden / filename / rendered entity / field
When selecting 'rendered entity' you can specify a view mode, when selecting 'field', you can select a field from the image entity type.
Needed to add some additional allowed tags and toy with the javascript a little to match possibly complex html in the caption attribute.
Comment #10
Karsa CreditAttribution: Karsa commentedOh, and - as requested - this patch applies to branch 7.x-1.x-dev.
Comment #11
gifad CreditAttribution: gifad commentedThis new functionality is interesting, but, please, do not remove the “File title” option !
Thanks,
Comment #12
Karsa CreditAttribution: Karsa commentedAdding it in the first place was a mistake, file entities don't have titles, only filenames. :)
(The file entity label is the filename, it doesn't have a separate "title" unless you add one - as a field, which this functionality fully supports).
See
entity_get_info('file')
:Comment #13
gifad CreditAttribution: gifad commentedThis issue is about fields, not files...
“File title” is not a mistake, perhaps it just could be better named “Image title” (or “Title text”, as other popular field formatters name it).
The description in drupal-7.22/modules/image/image.install is “Image title text, for the image's 'title' attribute.”
And it's a good candidate for the lightbox caption, too
Comment #14
Karsa CreditAttribution: Karsa commentedThe 'title text' and 'alt text' of the image entity are fields. Programmatically added fields, but fields nonetheless. I don't think there's any need to support them not as such, outside the already available field-as-caption functionality.
Comment #15
gifad CreditAttribution: gifad commented“already available field-as-caption” ?
On a fresh install I can't get it working :
“Rendered file” option gives an empty “view mode” select
“Field” option gives an empty “Field” select
after firing twice this php notice :
Location http://.../system/ajax
Message Warning: Invalid argument supplied for foreach() in form_select_options() (line 2674 of .../drupal-7.22/includes/form.inc).
Am I missing something ?
Comment #16
Karsa CreditAttribution: Karsa commentedAh, you must not be using the file_entity module. Ok, we could probably add this functionality when file_entity is missing AND hide the field functionality as well.
Can you maybe work on this? I won't be able to code&fix this in the next couple of weeks or so.
Comment #17
gifad CreditAttribution: gifad commentedMade Karsa's improvements “Rendered entity as caption” at #9 conditioned by presence of file_entity module;
If file_entity is not present, choice is given to use title or alt fields of image, as the caption.
Comment #18
gifad CreditAttribution: gifad commentedFixed a php notice if file_entity module not enabled.
Comment #19
HyperGlide CreditAttribution: HyperGlide commentedPlus 1 for this patch!! Related to #2036023: Adjust "/manage/image/file-display" and like wise to NOT load Lightbox2 and other massively long list of "Enabled Displays"
Comment #22
joseph.olstadfixed in 7.x-2.0
if you want this fix then please upgrade to 7.x-2.0