Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Title for iframe/video in magnific popup

I need to show title/caption for video popup. In image type there is option for this, but none for video/iframe.

In docs (http://dimsemenov.com/plugins/magnific-popup/documentation.html#iframe_type) I found example of templating markup but I don't understand how to make title visible.

Would you please help me to setup iframe markup to show title in popup window from link like

<a class="popup" title="This is caption" href="http://vimeo.com/41128754"></a>

JS code

    $('a.popup').magnificPopup({
        disableOn: 700,
        type: 'iframe',
        mainClass: 'mfp-fade',
        removalDelay: 160,
        preloader: false,
        fixedContentPos: true,
        titleSrc: 'title'

    });

Thank you.

like image 609
Arkady Avatar asked Jul 12 '13 09:07

Arkady


People also ask

How do I use Magnific popup?

Get MagnificClick the Releases button in the center of the page. Then download the zip version of the source code for the latest versions. Find the file you downloaded and unzip it. The resulting folder should be called Magnific-Popup-master.

How do I use Magnific popup in react?

The easiest way to use react-magnific-popup is to install it from NPM and include it in your own React build process (using Browserify, Webpack, etc). You can also use the standalone build by including dist/react-magnific-popup. js in your page.

What is jQuery Magnific popup min js?

Magnific Popup is a responsive lightbox & dialog script with focus on performance and providing best experience for user with any device. (for jQuery or Zepto.js).

How do I get rid of Magnific popup?

We can close magnific popup in various ways We can add a button within the popup and assign a function on click event like $('#close-button-verify'). click(function(){ //This will close the most recently popped dialog //This method specially works for auto popped dialogs i.e. //Popup you opened using $. magnificPopup.


1 Answers

A bit late, but it may be helpful to anyone else looking for the answer.

The "titleSrc" attribute only applies to type: image, it doesn't work for iframes. The developer of Magnific Popup has an example of how to add a title to an iframe popup here: http://codepen.io/dimsemenov/pen/zjtbr

This is the JS:

$('.popup').magnificPopup({
  type: 'iframe',
  iframe: {
     markup: '<div class="mfp-iframe-scaler">'+
                '<div class="mfp-close"></div>'+
                '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
                '<div class="mfp-title">Some caption</div>'+
              '</div>'
  },
  callbacks: {
    markupParse: function(template, values, item) {
     values.title = item.el.attr('title');
    }
  },
  // your other settings
});

To make the title appear, you must include this CSS:

.mfp-title {
  position:absolute;
  /* other formatting */
}

What this is doing:

  • markup is adding a new div with class mfp-title to the frame wrapper, that will be used to display the caption.
  • The markupParse callback gets the title attribute from the link if there is one, and adds it to the new div.
  • That this adds the title to the bottom of the video, regardless of where the .mfp-title div is included, as it uses absolute positioning. You need to use CSS to position it at the top, e.g. top: -20px; left:0; (you'll need a negative value for the top to move it above the iframe)

.

The developer has a collection of examples here that might help anyone looking for how to do things not covered in the documentation. http://codepen.io/collection/nLcqo/

like image 52
FluffyKitten Avatar answered Sep 20 '22 06:09

FluffyKitten