} global $post, $product, $woocommerce; $attachment_ids = $product->get_gallery_attachment_ids(); if ($attachment_ids) { $loop = 0; $columns = apply_filters('woocommerce_product_thumbnails_columns', 3); ?> <div class="thumbnails <?php echo 'columns-' . $columns; ?> "><?php foreach ($attachment_ids as $attachment_id) { $classes = array('zoom'); if (0 === $loop || 0 === $loop % $columns) { $classes[] = 'first'; } if (0 === ($loop + 1) % $columns) { $classes[] = 'last'; } $image_class = implode(' ', $classes); $props = wc_get_product_attachment_props($attachment_id, $post); if (!$props['url']) { continue; } echo apply_filters('woocommerce_single_product_image_thumbnail_html', sprintf('<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>', esc_url($props['url']), esc_attr($image_class), esc_attr($props['caption']), wp_get_attachment_image($attachment_id, apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail'), 0, $props)), $attachment_id, $post->ID, esc_attr($image_class)); $loop++; } ?> </div> <?php }
* (the theme developer) will need to copy the new files to your theme to * maintain compatibility. We try to do this as little as possible, but it does * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * * @see https://docs.woothemes.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 2.0.14 */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } global $post, $product; ?> <div class="images"> <?php if (has_post_thumbnail()) { $attachment_count = count($product->get_gallery_attachment_ids()); $gallery = $attachment_count > 0 ? '[product-gallery]' : ''; $props = wc_get_product_attachment_props(get_post_thumbnail_id(), $post); $image = get_the_post_thumbnail($post->ID, apply_filters('single_product_large_thumbnail_size', 'shop_single'), array('title' => $props['title'], 'alt' => $props['alt'])); echo apply_filters('woocommerce_single_product_image_html', sprintf('<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" data-rel="prettyPhoto' . $gallery . '">%s</a>', $props['url'], $props['caption'], $image), $post->ID); } else { echo apply_filters('woocommerce_single_product_image_html', sprintf('<img src="%s" alt="%s" />', wc_placeholder_img_src(), __('Placeholder', 'woocommerce')), $post->ID); } do_action('woocommerce_product_thumbnails'); ?> </div>
/** * Returns an array of data for a variation. Used in the add to cart form. * @since 2.4.0 * @param WC_Product $variation Variation product object or ID * @return array */ public function get_available_variation($variation) { if (is_numeric($variation)) { $variation = wc_get_product($variation); } return apply_filters('woocommerce_available_variation', array_merge($variation->get_data(), array('attributes' => $variation->get_variation_attributes(), 'image' => wc_get_product_attachment_props($variation->get_image_id()), 'weight_html' => wc_format_weight($variation->get_weight()), 'dimensions_html' => wc_format_dimensions($variation->get_dimensions(false)), 'price_html' => apply_filters('woocommerce_show_variation_price', $variation->get_price() === "" || $this->get_variation_price('min') !== $this->get_variation_price('max'), $this, $variation) ? '<span class="price">' . $variation->get_price_html() . '</span>' : '', 'availability_html' => wc_get_stock_html($variation), 'variation_id' => $variation->get_id(), 'variation_is_visible' => $variation->variation_is_visible(), 'variation_is_active' => $variation->variation_is_active(), 'is_purchasable' => $variation->is_purchasable(), 'display_price' => wc_get_price_to_display($variation), 'display_regular_price' => wc_get_price_to_display($variation, array('price' => $variation->get_regular_price())), 'dimensions' => wc_format_dimensions($variation->get_dimensions(false)), 'min_qty' => 1, 'max_qty' => $variation->backorders_allowed() ? '' : $variation->get_stock_quantity(), 'backorders_allowed' => $variation->backorders_allowed(), 'is_in_stock' => $variation->is_in_stock(), 'is_downloadable' => $variation->is_downloadable(), 'is_virtual' => $variation->is_virtual(), 'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no', 'variation_description' => $variation->get_description())), $this, $variation); }
/** * Get the product thumbnail, or the placeholder if not set. * * @subpackage Loop * @param string $size (default: 'shop_catalog') * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0) * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0) * @return string */ function woocommerce_get_product_thumbnail($size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0) { global $post; $image_size = apply_filters('single_product_archive_thumbnail_size', $size); if (has_post_thumbnail()) { $props = wc_get_product_attachment_props(get_post_thumbnail_id(), $post); return get_the_post_thumbnail($post->ID, $image_size, array('title' => $props['title'], 'alt' => $props['alt'])); } elseif (wc_placeholder_img_src()) { return wc_placeholder_img($image_size); } }
function hocwp_wc_single_product_image_html($html, $post_id) { $thumbnail_zoom = hocwp_wc_single_product_thumbnail_zooming(); if ($thumbnail_zoom) { global $post, $product; if (has_post_thumbnail()) { $image_ids = $product->get_gallery_attachment_ids(); $count = count($image_ids); $gallery = $count > 0 ? '[product-gallery]' : ''; $thumb_id = get_post_thumbnail_id(); $props = wc_get_product_attachment_props($thumb_id, $post); $image_url = $props['url']; $size = get_option('shop_single_image_size'); $size = hocwp_sanitize_size($size); $size = apply_filters('single_product_large_thumbnail_size', $size); $args = array('title' => $props['title'], 'alt' => $props['alt']); $image = get_the_post_thumbnail($post, 'full', $args); $html = sprintf('<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" data-rel="prettyPhoto%s">%s</a>', esc_url($image_url), esc_attr($props['caption']), $gallery, $image); $html = apply_filters('hocwp_wc_single_product_image_html', $html, $post->ID); } } return $html; }