Make drowl_paragraphs Photoswipe 5 compatible

Created on 15 July 2022, over 2 years ago
Updated 18 August 2023, over 1 year ago

Problem/Motivation

Photoswipe is broken, e.g. for Galleries, if the Photoswipe Global option (admin/config/media/photoswipe) is disabled.

Presumably we need this [5.x] Make photoswipe library attachable in theme ({ attach_photoswipe() }) Fixed issue to be fixed and could then require it in our library as dependency?

Warning / internal note: In our VL we sem to load it globally in the theme or something like that, be careful and better test with other OLD sites or remove the hack before.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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.

  • 🇩🇪Germany Grevil

    The problem is, that we currently attach photoswipe twice. Once through this code inside the drowl_paragraphs module file:

    /**
     * Helper function for image paragraph types with field "image_zoomable".
     */
    function _drowl_paragraphs_types_preprocess_paragraph_image_zoomable(&$variables) {
      // TODO: Remove all this and put a simply {{ attach_library('photoswipe/photoswipe.init') }}
      // into flexible_image.html.twig to initialize photoswipe, once
      // photoswipe doesn't need a HTML5 template anymore.
      // That will be the case with Photoswipe v5!
      // for details see https://www.drupal.org/project/drowl_paragraphs/issues/3345294
      $paragraph = $variables['paragraph'];
      if ($paragraph->hasField('field_paragraphs_image_zoomable') && !$paragraph->get('field_paragraphs_image_zoomable')->isEmpty()) {
        // Attach the photoswipe library and template, if zoom is enabled:
        \Drupal::service('photoswipe.assets_manager')->attach($variables);
      }
    }

    And once through the photoswipe 'Load PhotoSwipe on all non-admin pages' option and adding the 'photoswipe' class to the image link in flexible_image.html.twig. Furthermore, the pswp data attributes are not compatible with Photoswipe 5 (as @thomas.frobieter pointed out).

    data-size="1280x397" (old) vs. data-pswp-width="1280" / data-pswp-height="618" (new)

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Composer require failure
  • @grevil opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany Grevil

    Ok, all done, should work with photoswipe 5 now. We need to make sure to disable the global photoswipe option once enabled.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Composer require failure
  • 🇩🇪Germany Anybody Porta Westfalica

    @thomas.frobieter releasing this will force us to upgrade all pages using drowl_paragraphs 4.x to use Photoswipe 5. From my perspective that's okay and better than having one additional branch. Do you agree?

  • 🇩🇪Germany Grevil

    All resolved, please review! Once again.

  • Looks good to me! I'll create a new release.

  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024