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.
Tokenize
Please provide a token approach for generating captions. Basically we have two general situations: (1) token module enabled and (2) not enabled. For #1 - no comments needed. For #2 we could have the current ruleset for titles.
Subcaption
I would be over the moon if there was a separate, configurable, subcaption field. The subcaption would adopt tokens, and not render out at all if it were empty. This would allow for a nicer interface with actualy 2 lines of text. I would use first for the Node title, and the other for alt/title of the image.
Comment | File | Size | Author |
---|---|---|---|
#10 | shadowbox-tokenize-1589962-10.patch | 10.24 KB | manfer |
#5 | shadowbox-tokenize-1589962-4.patch | 10.23 KB | manfer |
#3 | shadowbox-tokenize-1589962-3.patch | 10.34 KB | manfer |
Comments
Comment #1
rggoode CreditAttribution: rggoode commentedwould it also be possible to allow for links to be in the caption? I have a view of gallery thumbnails from image nodes. I'd like to have people view the images from the gallery in Shadowbox, but then, if they want more information on an image while in shadowbox, click on a "view details" link in the caption adn go to the image node.
Comment #2
manfer CreditAttribution: manfer commentedNot something related to shadowbox.
You may try to look at the module imageField Tokens or similar.
Comment #3
manfer CreditAttribution: manfer commentedBorrowing code from colorbox module here is a patch to tokenize the captions
Comment #4
manfer CreditAttribution: manfer commentedComment #5
manfer CreditAttribution: manfer commentedMinor change on the patch to correct an issue with the visibility of tokenize form fields in views
Comment #6
moniuch CreditAttribution: moniuch commentedI have just had an opportunity to try out the patch. In general it applies and works, thanks for that.
I only regret the scope of available tokens is global and does not take the entity in account. But then I thought that for what I want to achieve actually the best option would be a title callback/hook. Something that would allow me to employ my own logic, such as:
Comment #7
manfer CreditAttribution: manfer commentedWith tokens you have access to the values of the file uploaded in the field. Using [file:field_file_image_title_text] and [file:field_file_image_alt_text] tokens you have access for example to the new media 2.x text and alt values.
But I have found a bug on this patch that makes it fail for the image field, I will upload a new patch as soon as possible.
Comment #8
moniuch CreditAttribution: moniuch commentedStill, in my case with tokens I would get "Node title:" when alt_or_title is not set. With a callback function I would have more flexibility to toss out the trailing colon.
Thanks for your immediate responses and patches though! Much appreciated!
Comment #9
manfer CreditAttribution: manfer commentedI'm going to quote here an answer by David Reid to a similar problem
I think the custom token module (with the help of php filter module to allow PHP code on those tokens) is what you need to create your own specific tokens.
I'm going to modify this patch to correct the bug I found that makes tokens not work properly in the image field with shadowbox display format.
Comment #10
manfer CreditAttribution: manfer commented