I know this issue has come up before, but I couldn't pinpoint a thread to refer to, so I apologize if I am rehashing anything here.
We had a need for inserting a customizable link to the Colorbox caption, which isn't possible using the "title" field. So I came up with a solution for the 7.x-1.x version. We'd like to move to 7.x-2.x, so I thought I'd try and rework the solution and share as a patch.
The attached images show the end goal - a customizable field for "Link on caption" both in Views (on a per image basis) and on the Content Type display interface (set once for all images - though using tokens could individualize).
Comment | File | Size | Author |
---|---|---|---|
#9 | colorbox.zip | 177.67 KB | userspan |
#7 | view_v2.jpg | 81.3 KB | mxwright |
#7 | content_type_display_v2.jpg | 137.89 KB | mxwright |
#6 | link-on-caption-2385713-6.patch | 5.36 KB | mxwright |
#5 | jquery.colorbox.js_.zip | 13.45 KB | mxwright |
Comments
Comment #1
mxwright CreditAttribution: mxwright commentedAnd a patch
Comment #2
mxwright CreditAttribution: mxwright commentedUnfortunately, the downside to this patch, or this method in general, which adds a new "url" field to the colorbox href surrounding the image, is that you have to also modify the colorbox library so that the new field will be picked up. The changes are small but significant and the patch can't work without them. If someone has a better method for hooking the changes in, rather than modifying the library, that would be great. In the meantime, here are the fully modified jquery.colorbox.js and jquery.colorbox-min.js files. Just unzip and drop them into your Colorbox library directory.
Comment #3
mxwright CreditAttribution: mxwright commentedFYI, I am working on a new version of the patch that operates more like the "Caption" field, allowing the field to be set to "title text", "alt text", "custom (with tokens)", or "none". That way, one could utilize the alt text, for example, to set a link on an individual level when not using Views. That one is hopefully forthcoming.
Comment #4
mxwright CreditAttribution: mxwright commentedComment #5
mxwright CreditAttribution: mxwright commentedCorrected mistake in colorbox library where items using "colorbox-load" class would not load due to missing "url" parameter. Disregard upload in #2 above. Should work now.
Comment #6
mxwright CreditAttribution: mxwright commentedOK, here's the new version of the patch, featuring title, alt text, and custom/tokens.
Comment #7
mxwright CreditAttribution: mxwright commentedThe patch in #6 above should have a slightly updated look on the admin side, as evidenced by the two attached pics. It now looks and acts much like the "Caption" field.
Comment #8
rooby CreditAttribution: rooby commentedWhy is this a new field at all?
What about just allowing colorbox_caption_custom to accept and render links?
The title attribute can contain links, however they need to have their html entities encoded. What makes it not possible is the use of Drupal's l() function to create the link. That function will stop you putting links in the title attribute.
In my case I overrode that theme function and manually created the a tag markup instead of using l() and then I could put links in there.
If we changed the original theme_colorbox_imagefield() function it would likely solve this without having to have the additional fields and javascript.
Comment #9
userspan CreditAttribution: userspan as a volunteer commentedComment #10
Neslee Canil PintoPatch failed to apply.
Comment #11
Neslee Canil Pinto