【发布时间】:2014-05-26 06:54:12
【问题描述】:
我有一个页面,我需要在 Magnific lightbox 中发布视频,但在它下面我添加了一个“项目详细信息”链接以及社交媒体图标。它看起来像这样:
插件支持回调:
// Initialize Magnefic Lightbox
$('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
iframe: {
markup:
'<div class="mfp-iframe-scaler">'+
'<div class="mfp-close"></div>'+
'<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
'</div>'+
'<div class="after-iframe">'+
'<div class="details-link"><i class="icon-link"></i> <a class="project-link" href="#">Project Details</a></div>'+
'<div>[Sharing Buttons]</div>'+
'</div>'
},
delegate: 'a',
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: true,
fixedContentPos: false,
callbacks: {
open: function() {
// Will fire when this exact popup is opened
// this - is Magnific Popup object
initShare();
},
close: function() {
// Will fire when popup is closed
}
}
});
当我在 WordPress 中创建帖子循环时,我需要从页面中获取永久链接并将其作为唯一变量传递给正确的实例。不幸的是,这有点超出我的想象,因为我的 JS 技能并不完全符合我的期望。我的 PHP 循环模板(放弃所有变量定义)如下所示:
<li>
<div class="overlay-box popup-vimeo">
<img itemprop="image" data-interchange="[<?php echo $img_std[0]; ?>, (default)], [<?php echo $img_retina[0]; ?>, (retina)]" alt="<?php the_title(); ?>" />
<noscript><img src="<?php echo $img_std[0]; ?>" alt="<?php the_title(); ?></noscript>
<div class="details">
<h3><?php the_title(); ?></h3>
<p><?php echo get_the_excerpt(); ?></p>
<p class="details-link mobile-only"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<p class="tiny button alignright"><i class="icon-play"></i> Play Video</p>
</div>
<a class="play-it desk-only" href="<?php echo $thisvid; ?>" title="{<?php the_title(); ?> - Watch Video}"><span></span></a>
</li>
据我所知,the click capture being used in this solution 正朝着正确的方向前进。
一旦我知道如何添加回调并获得“项目详细信息”链接以运行,那么我应该能够应用相同的技术来传递社交媒体链接。一旦我有了初步的解决方案,这对我来说是一个很好的练习。
我真的,真的,真的需要在第一部分得到帮助,因为我以前没有这样做过,而且我对 JS 作用域的理解可能比现在强得多 =/
【问题讨论】:
标签: jquery wordpress lightbox magnific-popup