Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently the available options for "Caption" under the display options for Colorbox are "Automatic, Title text, Alt text, No title, None". Placeholder tokens would allow for ultimate control, e.g. "[node:title] - [node:field-url]". I am aware of the views colorbox trigger field, but this would be a much more practical and simplistic option in my opinion.
Comment | File | Size | Author |
---|---|---|---|
#7 | 1290208-colorbox-token.patch | 641 bytes | andypost |
#1 | colorbox_token_support.patch | 3.12 KB | frjo |
Comments
Comment #1
frjo CreditAttribution: frjo commentedI have been meaning to add this but never got around to it. Thanks for reminding me!
Please try the attach patch and report back your results here.
Comment #2
benmalen CreditAttribution: benmalen commentedThank you so much, frjo! I applied the patch and it works great.
I have one problem however, as I want to show an actual URL in the caption but the tokens are stripped of all HTML.
For example, currently it will output something like this:
I want to output with encoded HTML like this:
I had a go at making modifications, but unfortunately I am a bit rusty on the development side so it did not work out. I hope you may be able to help me with this.
Comment #3
kaylsbeth CreditAttribution: kaylsbeth commentedI also applied the patch, frijo, and it worked beautifully! Thank you!
Comment #4
frjo CreditAttribution: frjo commentedCommitted to 7-dev.
@benmalen, I don't believe HTML is allowed inside the title attribute. That’s why Drupal l() function that colorbox use to build link strips it out.
Comment #5
benmalen CreditAttribution: benmalen commentedHmm, I used to use Lightbox and you could use HTML in the caption so I was hoping this could be done with Colorbox.
http://www.huddletogether.com/projects/lightbox2/
I guess I can make do without. Thanks again.
Comment #6
andyposttoken_replace() is a core's function, so there's no dependency on token module. Field settings could be stored in-code or provided with features module. Token is useful when you editing setting.
Code should be:
Comment #7
andypostI mean this! Only settings are depends on token module
Comment #8
frjo CreditAttribution: frjo commentedThanks for catching my mistake andypost, committed the fix to 7-dev now.
Comment #9
kaylsbeth CreditAttribution: kaylsbeth commentedSo, here's a question stemming, I think, from the tokens. I want to create a space for lengthier captions to exist using these tokens... in theory I could do this with title, but it's not long enough. How can I tie something up with each separate image that I could then use the tokens to implement? IE a separate caption field for each image. When Image wasn't tied up with the core in 6, this might have been a bit easier... I'm just hoping I won't have to create a new content type to try and get this to work.