How do I set juicebox gallery title and caption programmatically?

Created on 19 September 2014, almost 10 years ago
Updated 11 October 2014, over 9 years ago

I need to set, replace, title and caption of my juicebox galleries programmatically .
The caption should include links with SKU numbers linked to the products within respective image.
-- examples by hook_juicebox_gallery_alter ($ juicebox, $ data) {??
// ---- foreach ($ variables ['field_reference_image'] as $ cnt => $ image) {
$variables ['field_reference_image'] [$ cnt] ['title'] = $ title. 'image '. $ cnt + 1;
$variables ['field_reference_image'] [$ cnt] ['image_field_caption'] ['value'] = $image_caption [$cnt];
}
// ---- How do I solve this the best way?
--- check documentation & code ?;-) -- bogart

πŸ’¬ Support request
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Hi again Ryan, yes first time was round 8-9 years ago... I'd ask you the same question regarding Drupal 7 and the Juicebox, I remember the usage of Preprocessing some of the existing variables before I displayed them ie, titles and caption. Now we are talking about an update of the same site with twig templates involved..? I'm retired but still helping the company with the site development.
    Learning Twig is brainwashing for me, I've tested a lot of things regarding Drupal 9. But hard for me to understand why I can't get twig to display my updated variables by running the same preprocess function on the Juicebox vars? Ok maybe I should re-render the images...but that's done twice??
    Things should be updated by the system it self, but It aint working?
    Ok I've cleaned the cache several times, but still no luck? Clean the cache, is it that simple?
    Now I've tried the module alternative and the suggested juicebox_alter_function instead to make my changes before the image was twig rendered by the system.
    Are there any module sample altering the juicebox-images texts before they are displayed?
    Can't get the 'alter' stuff function within my module to fire up at all?
    Maybe I've missed something?
    The question: What's the best practice regarding preprocess Juicebox vars and get twig template displaying the update?

    Kindest regards Bogart

Production build 0.69.0 2024