Closed (fixed)
Project:
GLightbox
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2024 at 13:29 UTC
Updated:
6 Mar 2025 at 16:42 UTC
Jump to comment: Most recent
Having lean media for reusability is a common practice I've been seeing lately, you create a Media bundle with the minimum so it can be reused and then the configurable bit lives on paragraphs (or other), but mainly paragraphs.
This module has already clever implementations for parent paragraphs on the gallery side, but it would be nice to have paragraph token replacement too.
Add paragraph as a token entity on the formatter form, then load it if exists when the replace happens.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pcambraWorking on a patch
Comment #4
pcambraIf this is an acceptable solution, I'll add an equivalent MR to https://www.drupal.org/project/glightbox_media_video
Comment #5
pcambraComment #6
pcambraComment #8
levmyshkinHi 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_name
From first glance, it should be straightforward, but I'm afraid that Drupal doesn't support parent entity, because of circullar tokens (I suppose so, 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
Here 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.
Comment #9
levmyshkinI merged your request in 1.0.x-dev. I will try to add tokens on the next week.
Comment #10
levmyshkinComment #11
levmyshkinComment #12
zany commentedI 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?
Comment #13
zany commentedOn closer inspection I see the issue with my use-case:
glightbox.theme.incproperly 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 setparentor such instead ofparagraph(which hides the current entity)?Comment #14
levmyshkinHi 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