- Issue created by @pcambra
- Merge request !5Issue #3487478: Allow caption tokens from parent (paragraph entity) → (Merged) created by pcambra
- 🇪🇸Spain pcambra Asturies
If this is an acceptable solution, I'll add an equivalent MR to https://www.drupal.org/project/glightbox_media_video →
- 🇷🇸Serbia levmyshkin Novi Sad, Serbia
Hi pcambra, it will be tricky to define 'mainly' paragraph automatically. Glightbox image formatter which is being applied to Image field can be referenced to Media entity first and Media field attached in Paragraph directly or in nested paragraph with Gallery and Gallery Item paragraph types. Image field can be included in 'mainly' Gallery paragraph type directly. Paragraph module is not limited by any structure or nested levels.
It's possible to prepare tokens for specific (common, most popular) cases:
1. Multiple image field inside 'mainly' Paragraph (without Media).
2. Single image field in paragraph Gallery Item and Gallery 'mainly' parent paragraph type (without Media).
3. Multiple media field inside 'mainly' Paragraph.
4. Single media field in paragraph Gallery Item and Gallery 'mainly' parent paragraph type.It can be one token 'Parent title', but here is another problem, which field must be selected for this token. Gallery id is being generated automatically without additional complexity with Text field at the end.
It can be token by reference:
referenece_field_name:parent_entity:reference_field_name:parent_entity:text_field_nameFrom first glance, it should be straightforward, but I'm afraid that Drupal doesn't support parent entity, because of circullar tokens (parent entities support children fields tokens, children fields tokens support parent fields tokens) and it must be tricky too:
https://www.drupal.org/project/paragraphs/issues/3067265 ✨ Paragraph templates: unable to access parent-node tokens from child-paragraphs in the default installed setup Needs reviewHere is a custom solution to create own site specific token:
https://drupal.stackexchange.com/questions/254406/how-to-get-token-of-pa...I can create only 4 tokens for cases above, then it will be possible to select field for token, but site editor must be aware which token relates for his own site depends on its structure.
- 🇷🇸Serbia levmyshkin Novi Sad, Serbia
I merged your request in 1.0.x-dev. I will try to add tokens on the next week.
- Status changed to Fixed
about 2 months ago 12:26pm 4 March 2025 - 🇩🇪Germany zany
I have e.g. a "gallery" paragraph with "field_gallery_items" and "field_label", and a (nested) "gallery_items" paragraph with "field_image" and "field_description".
I want to use the "field_description" (which is alongside the "field_image") as custom caption description.
I notice the following: I can use "[paragraph:id]" (shows the same value on all glightbox images) and "[paragraph:field_label:value]" for custom caption and custom caption description (from the parent paragraph).
But I can not use "[paragraph:field_description:value]" (from the direct paragraph containing this "field_image").Is the paragraph token supposed to be the direct paragraph entity containing the glightbox formatted field? Or is this intentionally the parent paragraph?
- 🇩🇪Germany zany
On closer inspection I see the issue with my use-case:
glightbox.theme.inc
properly sets
$data = [$entity_type => $entity, 'file' => $item];
in line 303 -- which in my case sets a "paragraph" entity.
But line 307 overrides this with$data['paragraph'] = $parent;
-- should this maybe setparent
or such instead ofparagraph
(which hides the current entity)? - 🇷🇸Serbia levmyshkin Novi Sad, Serbia
Hi pcambra, I updated tokens for GLightbox paragraphs, please, use [paragraph_container:field_name] token for your Image/Media field:
https://www.drupal.org/project/glightbox/issues/3511270#comment-16018183 🐛 Allow caption tokens paragraph access if there is a parent paragraph Active