Search code examples
javascriptjqueryiframemagnific-popupclassname

Magnific Popup - add additional class to iframe


First of all , thanks for the great "Magnific Popup" plugin! I have a beginner' question. I'm using an iframe type. I'm showing several types of sites in the iframe , most of them are responsive and takes all the width of iframe. But in some cases when a site is not responsive , i want to add some specific class , in which i set absolute value for width , to the iframe . What is a most proper way to do it?

$.magnificPopup.open({
  items: {              
    src: myUrl,          
    type: 'iframe',
    class: '.bad-site-class' // Is there something like 'class'?
   }
});

Thank you and have a good autumn!

(Yoo-hoo , this is 100th question tagged 'magnific popup'! :) )


Solution

  • You may use markupParse callback, e.g.:

    callbacks: {
       markupParse: function(template, values, item) {
           template.find('iframe').addClass('bad-site-class');
       }
    }
    

    http://dimsemenov.com/plugins/magnific-popup/documentation.html#api