- Issue created by @hungdo
- πΊπΈUnited States fkelly
Thanks for the patch. I applied most of this to my ddev based local site that is derived from 4.0.0-alpha2. Previously I had applied some changes to alpha2 based on PHPstorm suggestions. I had also run PHPCS locally in an effort to resolve "Resolve all coding standard violations" issue #3351683. At one point I had PHPCS running without errors but then got bogged down with other priorities.
The patch seems to apply okay. On my dev site I can run a Juicebox Gallery with it. If you've worked with PHPstorm you'll know that it makes a zillion other suggestions for tweaks to the code. Such tweaks can, on occasion cause problems within Drupal.
The full text of the revised function as implemented now on my dev system is:
protected function buildGallery(JuiceboxGalleryInterface $gallery, FieldItemListInterface $items): void { // Get settings. $settings = $this->getSettings(); // Iterate over items and extract image data. foreach ($items as $item) { if ($item->getPluginId() === 'field_item:entity_reference') foreach ($item->entity->getFields() as $field_name => $field) if ($field->getFieldDefinition()->getType() === 'image' && (str_contains($field_name, 'field_'))) { $item = $item->entity->{$field_name}[0]; break; } if ($item->isDisplayed() && !empty($item->target_id)) { // Set the image title. If we have an incompatible file and are // configured to show a link, set the title text as the link. $src_data = $this->juicebox->styleImageSrcData($item->entity, $settings['image_style'], $item->entity, $settings['thumb_style'], $settings); if (!$src_data['juicebox_compatible'] && $settings['incompatible_file_action'] == 'show_icon_and_link') { $anchor = !empty($item->description) ? $item->description : $item->entity->get('filename')->value; $title = $this->linkGenerator->generate($anchor, Url::fromUri($src_data['linkURL'])); } else { $title = $this->getFieldText($item, $settings['title_source']); } // Set the image caption. $caption = $this->getFieldText($item, $settings['caption_source']); // Add this image to the gallery. $gallery->addImage($src_data, $title, $caption); } }
You are welcome to test this on your own sites after manually applying the patch. Please let us know if it resolves the issues you have reported. To really move beyond alpha2 we need to have a release run through the test suite and fix up any remaining coding discrepancies.
Problem is that maintainer time for this contrib project is limited and, at least in my case expertise is limited too. I am also focusing most of my remaining Drupal time on coming up with an alternative approach to galleries using the Solo theme and paragraphs based modules. This will give an option that does not rely on non-open source and minimally support JS code.