PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/single-product/product-thumbnails.php

https://github.com/alexcsandru/woocommerce
PHP | 45 lines | 24 code | 14 blank | 7 comment | 9 complexity | 15d7595e07b23d4bf227af078bffb3d7 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Single Product Thumbnails
  4. *
  5. * @author WooThemes
  6. * @package WooCommerce/Templates
  7. * @version 1.6.4
  8. */
  9. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  10. global $post, $product, $woocommerce;
  11. $attachment_ids = $product->get_gallery_attachment_ids();
  12. if ( $attachment_ids ) {
  13. ?>
  14. <div class="thumbnails"><?php
  15. $loop = 0;
  16. $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 3 );
  17. foreach ( $attachment_ids as $id ) {
  18. $classes = array( 'zoom' );
  19. if ( $loop == 0 || $loop % $columns == 0 )
  20. $classes[] = 'first';
  21. if ( ( $loop + 1 ) % $columns == 0 )
  22. $classes[] = 'last';
  23. $attachment_url = wp_get_attachment_url( $id );
  24. if ( ! $attachment_url )
  25. continue;
  26. printf( '<a href="%s" title="%s" rel="prettyPhoto[product-gallery]" class="%s">%s</a>', esc_attr( $attachment_url ), esc_attr( get_the_title( $id ) ), implode( ' ', $classes ), wp_get_attachment_image( $id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) ) );
  27. $loop++;
  28. }
  29. ?></div>
  30. <?php
  31. }