Trufa
Trufa

Reputation: 40717

How can I combine inline elements with images in magnific popup having a displayed gallery

I am using Magnific Popup.

I can get it to work with galleries.

$(document).ready(function() {
    $('.popup-gallery').magnificPopup({
        delegate: 'a',
        type: 'image',
        gallery: {
            enabled: true,
            navigateByImgClick: true,
        }
    });
});

I can also actually mix inline elements with images which is basically what I want:

$('#open-popup').magnificPopup({
    items: [
      {
        src: 'http://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Peter_%26_Paul_fortress_in_SPB_03.jpg/800px-Peter_%26_Paul_fortress_in_SPB_03.jpg',
        title: 'Peter & Paul fortress in SPB'
      },
      {
        src: 'http://vimeo.com/123123',
        type: 'iframe' // this overrides default type
      },
      {
        src: $('<div class="white-popup">Dynamically created element</div>'), // Dynamically created element
        type: 'inline'
      },
      {
        src: '<div class="white-popup">Popup from HTML string</div>', // HTML string
        type: 'inline'
      },
      {
        src: '#my-popup', // CSS selector of an element on page that should be used as a popup
        type: 'inline'
      }
    ],
    gallery: {
      enabled: true
    },
    type: 'image' // this is a default type
});

My problem is that in the mixed example, I don't have the thumbnail "gallery" displayed, what I basically want is thumnail images, that when clicked behave like a gallery but with one inline element in between.

The inline element will have a thumbnail (and actual image), but when clicked will be an inline element.

I was able to do it with fancybox and you can see here if you click the thumbnails, it might help clarify what I need. (I am trying to achieve the same thing with Magnific popup with because of the lack of mobile support of mobile).

Upvotes: 0

Views: 6261

Answers (2)

Kusyka911
Kusyka911

Reputation: 3

jQuery(document).ready(function($) {
    $('.owl-wrapper').magnificPopup({
            delegate: 'a',
            type: 'image',
            tLoading: 'Loading image #%curr%...',
            mainClass: 'mfp-img-mobile',
            gallery: {
                enabled: true,
                navigateByImgClick: true,
                preload: [0,1]
            },
            image: {
                tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
            },
            callbacks: {
                elementParse: function(item) {
         if(item.el.context.className == 'video-link') {
             item.type = 'iframe';
         } else if(item.el.context.className == 'inline-link') {
            item.type = 'inline';
         } else {
             item.type = 'image';
         }
                }
            },
    });
});

Upvotes: 0

Dmytro Semenov
Dmytro Semenov

Reputation: 4616

You may add mfp-TYPE CSS class to thumbnail element that should have non-default content type. http://dimsemenov.com/plugins/magnific-popup/documentation.html#content_types

Upvotes: 2

Related Questions