Don't allow users to open the lightbox for placeholder images
This commit is contained in:
parent
366011ab20
commit
88a378ea79
|
@ -175,7 +175,7 @@ jQuery( function( $ ) {
|
|||
* Init PhotoSwipe.
|
||||
*/
|
||||
init_photoswipe: function() {
|
||||
$( '.woocommerce-product-gallery' ).prepend( '<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>' );
|
||||
$( '.woocommerce-product-gallery--with-images' ).prepend( '<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>' );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(a){if("undefined"==typeof wc_single_product_params)return!1;a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();if(b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}).on("woocommerce_init_gallery",function(){a.isFunction(a.fn.zoom)&&b.init_zoom()}),a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var b={init:function(){a.isFunction(a.fn.flexslider)&&this.init_flexslider(),a.isFunction(a.fn.zoom)&&this.init_zoom(),"undefined"!=typeof PhotoSwipe&&(this.init_photoswipe(),a(document).on("click",".woocommerce-product-gallery__trigger",this.trigger_photoswipe))},is_touch_device:function(){return"ontouchstart"in window||navigator.maxTouchPoints},init_flexslider:function(){a(".woocommerce-product-gallery").flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:!1})},init_zoom:function(){a(".woocommerce-product-gallery__image img").attr("width")>a(".woocommerce-product-gallery").width()&&(a(".woocommerce-product-gallery__image").trigger("zoom.destroy"),a(".woocommerce-product-gallery__image").zoom({touch:!1}))},get_gallery_items:function(){var b=a(".woocommerce-product-gallery__wrapper").children(),c=[],d=b.filter(".flex-active-slide").index();return b.length>0&&b.each(function(b,d){var e=a(d).find("img"),f=e.attr("data-large-image"),g=e.attr("data-large-image-width"),h=e.attr("data-large-image-height"),i={src:f,w:g,h:h,title:e.attr("title")};c.push(i)}),{index:d,items:c}},init_photoswipe:function(){a(".woocommerce-product-gallery").prepend('<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>')},trigger_photoswipe:function(c){c.preventDefault();var d=a(".pswp")[0],e=b.get_gallery_items(),f={index:e.index,shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0},g=new PhotoSwipe(d,PhotoSwipeUI_Default,e.items,f);g.init()}};b.init()});
|
||||
jQuery(function(a){if("undefined"==typeof wc_single_product_params)return!1;a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();if(b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}).on("woocommerce_init_gallery",function(){a.isFunction(a.fn.zoom)&&b.init_zoom()}),a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var b={init:function(){a.isFunction(a.fn.flexslider)&&this.init_flexslider(),a.isFunction(a.fn.zoom)&&this.init_zoom(),"undefined"!=typeof PhotoSwipe&&(this.init_photoswipe(),a(document).on("click",".woocommerce-product-gallery__trigger",this.trigger_photoswipe))},is_touch_device:function(){return"ontouchstart"in window||navigator.maxTouchPoints},init_flexslider:function(){a(".woocommerce-product-gallery").flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:!1})},init_zoom:function(){a(".woocommerce-product-gallery__image img").attr("width")>a(".woocommerce-product-gallery").width()&&(a(".woocommerce-product-gallery__image").trigger("zoom.destroy"),a(".woocommerce-product-gallery__image").zoom({touch:!1}))},get_gallery_items:function(){var b=a(".woocommerce-product-gallery__wrapper").children(),c=[],d=b.filter(".flex-active-slide").index();return b.length>0&&b.each(function(b,d){var e=a(d).find("img"),f=e.attr("data-large-image"),g=e.attr("data-large-image-width"),h=e.attr("data-large-image-height"),i={src:f,w:g,h:h,title:e.attr("title")};c.push(i)}),{index:d,items:c}},init_photoswipe:function(){a(".woocommerce-product-gallery--with-images").prepend('<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>')},trigger_photoswipe:function(c){c.preventDefault();var d=a(".pswp")[0],e=b.get_gallery_items(),f={index:e.index,shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0},g=new PhotoSwipe(d,PhotoSwipeUI_Default,e.items,f);g.init()}};b.init()});
|
|
@ -26,9 +26,10 @@ $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
|
|||
$full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' );
|
||||
$thumbnail_post = get_post( $post_thumbnail_id );
|
||||
$image_title = $thumbnail_post->post_content;
|
||||
$placeholder = has_post_thumbnail() ? 'with-images' : 'without-images';
|
||||
|
||||
?>
|
||||
<div class="woocommerce-product-gallery <?php echo 'woocommerce-product-gallery--columns-' . sanitize_html_class( $columns ) . ' columns-' . sanitize_html_class( $columns ); ?> images">
|
||||
<div class="woocommerce-product-gallery <?php echo 'woocommerce-product-gallery--' . $placeholder . ' woocommerce-product-gallery--columns-' . sanitize_html_class( $columns ) . ' columns-' . sanitize_html_class( $columns ); ?> images">
|
||||
<figure class="woocommerce-product-gallery__wrapper">
|
||||
<?php
|
||||
$attributes = array(
|
||||
|
|
Loading…
Reference in New Issue