admin管理员组文章数量:1315997
The gallery works correct as it should but every time that I had a link/url on the caption field it breaks the gallery.
Surely should be something around here .html(); thats is filtering the html tags.
ACF repeater:
<?php
if( have_rows('gallery') ):
?>
<div class="row">
<?php
while( have_rows('gallery') ) : the_row();
$image = get_sub_field('image');
$caption = get_sub_field('caption');
?>
<div class="col-md-4 mb-3 pl-2">
<figure class="image-holder">
<a href="<?php echo $image; ?>" data-fancybox="images">
<img class="gallery-img" src="<?php echo $image; ?>" />
<figcaption><?php echo $caption; ?></figcaption>
</a>
</figure>
</div>
<?php
endwhile;
else :
//echo "No images selected";
?>
</div>
<?php
endif;
?>
Script:
jQuery(document).ready(function($){
$( '[data-fancybox="images"]' ).fancybox({
caption : function( instance, item ) {
return $(this).find('figcaption').html();
},
toolbar : false,
smallBtn : true,
iframe : {
preload : false
},
beforeShow: function() {
$('.caption--image').remove();
},
afterShow: function() {
var caption = $(".fancybox-caption"),
innerCaption = caption.clone().addClass('caption--image');
$(".fancybox-slide--current .fancybox-content").append(innerCaption);
caption.not('.caption--image').addClass('caption--bottom');
}
});
});
The test can be executed on this codepen: codepen.io/fancyapps/pen/aaerxw
If we had a html tag such link inside the figcaption the gallery stops to work
本文标签: Fancybox3 ACF repeater URL strip out from the caption field
版权声明:本文标题:Fancybox3 ACF repeater. URL strip out from the caption field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741988612a2408835.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论