Search code examples
jquerymagnific-popup

Magnific Popup how to use dynamic url for iframe video


I want to get link for vimeo video in dynamic way like this:

jQuery('.overlay.showcases').magnificPopup({
    items: [
    {
        src: jQuery(this).find('a').attr('href'),
        type: 'iframe'
    }
    ]

});

but it now works...just show black vimeo screen, this is the html code:

<div class="overlay showcases">
    <a class="vimeolink" href="<?php echo get_field_escaped("vimeo_link"); ?>">Vimeo Link</a>
    <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?> 
</div>

How can I fix this?


Solution

  • I found solution for this:

    jQuery( ".overlay.showcase" ).click(function() {
        jQuery.magnificPopup.open({
          items: {              
            src: jQuery(this).find('a').attr('href'),          
            type: 'iframe'
           }
        });
    });
    

    Hope this will help someone else that have this problem.