function show_product_gallery($post, $single_options) { $single_options['enable_product_gallery'] = isset($single_options['enable_product_gallery']) ? $single_options['enable_product_gallery'] : ''; $single_options['enable_product_gallery_only_when_exist'] = isset($single_options['enable_product_gallery_only_when_exist']) ? $single_options['enable_product_gallery_only_when_exist'] : ''; if (is_lightbox_enabled() && $single_options['enable_product_gallery'] == 1) { $colorbox_set = apply_filters('colorbox_set', '{transition: "elastic", initialWidth: 200, maxWidth: "90%", maxHeight: "90%", rel:"gal"}'); ?> <script> jQuery(document).ready(function () { jQuery(".a-product-image").colorbox(<?php echo $colorbox_set; ?> ); }); </script> <?php } if ($single_options['enable_product_gallery'] == 1) { do_action('before_product_image'); ?> <div class="entry-thumbnail product-image"><?php do_action('above_product_image'); $image_size = apply_filters('product_image_size', 'medium'); if (has_post_thumbnail()) { if (is_lightbox_enabled()) { $img_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large'); ?> <a class="a-product-image" href="<?php echo $img_url[0]; ?> "><?php the_post_thumbnail($image_size); ?> </a> <?php } else { the_post_thumbnail($image_size); } } else { if ($single_options['enable_product_gallery_only_when_exist'] != 1) { echo default_product_thumbnail(); } } do_action('below_product_image', $post->ID); ?> </div> <?php do_action('after_product_image', $post->ID); } else { return; } }
/** * Returns whole product gallery for product page * * @param int $product_id * @param array $v_single_options * @return string */ function get_product_gallery($product_id, $v_single_options = null) { $single_options = isset($v_single_options) ? $v_single_options : get_product_page_settings(); if ($single_options['enable_product_gallery'] == 1) { $product_gallery = ''; ob_start(); do_action('before_product_image', $product_id); $product_gallery .= ob_get_clean(); $product_gallery .= '<div class="entry-thumbnail product-image">'; ob_start(); do_action('above_product_image', $product_id); $product_gallery .= ob_get_clean(); $image_size = apply_filters('product_image_size', 'medium'); if (has_post_thumbnail($product_id)) { if (is_lightbox_enabled()) { $img_url = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), 'large'); $product_gallery .= '<a class="a-product-image" href="' . $img_url[0] . '">' . get_the_post_thumbnail($product_id, $image_size) . '</a>'; } else { $product_gallery .= get_the_post_thumbnail($product_id, $image_size); } } else { if ($single_options['enable_product_gallery_only_when_exist'] != 1) { $product_gallery .= default_product_thumbnail(); } } ob_start(); do_action('below_product_image', $product_id); $product_gallery .= ob_get_clean(); $product_gallery .= '</div>'; ob_start(); do_action('after_product_image', $product_id); $product_gallery .= ob_get_clean(); return $product_gallery; } else { return; } }
/** * Shows product gallery on product page * * @param int $product_id * @param array $single_options * @return string */ function show_product_gallery($product_id, $single_options) { if ($single_options['enable_product_gallery'] == 1) { do_action('before_product_image'); ?> <div class="entry-thumbnail product-image"><?php do_action('above_product_image'); $image_size = apply_filters('product_image_size', 'medium'); if (has_post_thumbnail()) { if (is_lightbox_enabled()) { $img_url = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), 'large'); ?> <a class="a-product-image" href="<?php echo $img_url[0]; ?> "><?php the_post_thumbnail($image_size); ?> </a> <?php } else { the_post_thumbnail($image_size); } } else { if ($single_options['enable_product_gallery_only_when_exist'] != 1) { echo default_product_thumbnail(); } } do_action('below_product_image', $product_id); ?> </div> <?php do_action('after_product_image', $product_id); } else { return; } }