Installed correctly on the newest drupal.
Installed library and it is recognized.

In node type "Manage display" selected to show image as "Magnific popup".

When clicked on image it doesn't open any popup, but opens image in the browser instead.

CommentFileSizeAuthor
#4 magnific2.png18.63 KBElido

Comments

Elido created an issue. See original summary.

eric115’s picture

Category: Bug report » Support request
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Hi, I will need a few more details about your setup and which configuration options you are using to help you debug this. Can you please provide some more information?

Side note: Support requests like this are _not_ considered critical :)

david.qdoscc’s picture

I had the same issue. Checking the status report it showed that the library was not installed. The problem was the /dist folder in the library. I moved the JS files out of the /dist folder and placed them so that it was DRUPAL_ROOT/libraries/magnific-popup/jquery.magnific-popup.js etc. and it worked.

Elido’s picture

StatusFileSize
new18.63 KB

It says the magnific library is installed in the status report. And the files are placed correctly.

It looks like the magnific javascript is not initialized at all.

And Eric115, I consider it critical when the module is not working at all. :)

Elido’s picture

It says the magnific library is installed in the status report. And the files are placed correctly.

It looks like the magnific javascript is not initialized at all.

Elido’s picture

Priority: Normal » Critical

I consider it "critical" when the module is not working at all and not giving any errors.

Elido’s picture

I have reinstalled the module and the whole library by deleting folders and reinstalling again - still not initializing.

I use bootstrap theme.

Elido’s picture

Alright here I have fixed your module which is not working at all at any themes or installations of drupal 8.

Here is the fix:
---------------------------------------------------------------------------
1. Add two lines into viewElements function in the file:
src/Plugin/Field/FieldFormatter/MagnificPopup.php

  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    $thumb_image_style = $this->getSetting('thumbnail_image_style');
    $popup_image_style = $this->getSetting('popup_image_style');
    $gallery_type = $this->getSetting('gallery_type');
    $files = $this->getEntitiesToView($items, $langcode);
    foreach ($files as $delta => $file) {
      $image_uri = $file->getFileUri();
      $popup_image_path = !empty($popup_image_style) ? ImageStyle::load($popup_image_style)->buildUrl($image_uri) : $image_uri;
      // Depending on the outcome of https://www.drupal.org/node/2622586,
      // Either a class will need to be added to the $url object,
      // Or a custom theme function might be needed to do so.
      // For the time being, 'a' is used as the delegate in magnific-popup.js.
      $url = Url::fromUri(file_create_url($popup_image_path));
      $item = $file->_referringItem;
      $item_attributes = $file->_attributes;
      unset($file->_attributes);
      $item_attributes['class'][] = 'mfp-thumbnail';
      // ADDED THEESE TWO LINES
      $item_attributes['class'][] = 'mfp-field';      
      $item_attributes['class'][] = 'mfp-' . Html::cleanCssIdentifie;

-----------------------------------------------
js/magnific-popup.js is the following:

(function($, Drupal, drupalSettings) {
  "use strict";
  Drupal.behaviors.magnific_popup = {
    attach: function(context, settings) {
      // Gallery.
      $(context).find('.mfp-all-items, .mfp-first-item, .mfp-random-item').once('mfp-processed').each(function() {
var elem = $(this).parent().parent();
        elem.magnificPopup({
          delegate: 'a',
          type: 'image',
          gallery: {
            enabled: true
          },
          image: {
            titleSrc: 'alt'
          }
        });
      });
      // Separate items.
      $(context).find('.mfp-separate-items').once('mfp-processed').each(function() {
var elem = $(this).parent().parent();
        elem.magnificPopup({
          delegate: 'a',
          type: 'image',
          image: {
            titleSrc: 'alt'
          }
        });
      });
    }
  };
})(jQuery, Drupal, drupalSettings);

--------------------------------------------------------------------

Elido’s picture

Status: Postponed (maintainer needs more info) » Needs work
eric115’s picture

Priority: Critical » Normal
Status: Needs work » Closed (duplicate)

Hi Elido,

Thank you for your contribution. Would you kindly consider creating a patch (https://www.drupal.org/node/707484) with your changes in it so that I can properly test it against the code base?

I think the issue you are experiencing may be related to #2857287: Incorrect path for magnific library.

I would also strongly encourage you to read the issue queue etiquette here: https://www.drupal.org/node/1839650 :)

I am going to mark this as a duplicate for now, but please re-open the issue with a full description and steps to reproduce your issue, along with any errors you are seeing if you are still having trouble.

Thank you

Elido’s picture

Status: Closed (duplicate) » Needs review

This is not a dublicate, because the library is installed correctly and I have tried your patch and it still doesn't work

jay.dansand’s picture

Assigned: Elido » Unassigned
Status: Needs review » Closed (cannot reproduce)

@Elido: Thank you very much for bringing an issue to our attention! That said, in #10 Eric115 kindly requested that if you re-open the issue, you provide steps to reproduce your issue. Are you working on writing those steps? It may seem superfluous, but it's not: steps to reproduce are critical because the module works for us™ and works for over a thousand other sites; something is clearly different in your setup, and we need to be able to figure out what it is.

Side note 0: Read Drupal's issue queue etiquette. It's a really short list and I'm sure you'll have a happier Drupal experience if you take the 5 minutes to read it.

Side note 1: When supplying a patch, please supply a patch. We're volunteering our time around actual day jobs, and really can't afford the time to figure out manually merging your changes against git.

Side note 2: You may be unaware, but when you change issue status or post small messages 5 times in a row, it spams our email boxes; please try to keep everything as consolidated as possible.

Side note 3: Purely pedantic, but cccording to Drupal's issue priority policy, "support requests should never be marked 'critical' or 'major'."

TL;DR: We're volunteering out of our happy hearts to provide something at no cost to you. We want to help, but you need to help us help you (provide steps to reproduce, proper patches, following issue queue etiquette, etc.). Reopen with complete steps to reproduce, please. Thanks!