PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/CammoKing/woocommerce
PHP | 50 lines | 31 code | 12 blank | 7 comment | 10 complexity | 88031d75a7872e0f2d0b4a34e5437bfa 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, $woocommerce;
  11. ?>
  12. <div class="thumbnails"><?php
  13. $attachments = get_posts( array(
  14. 'post_type' => 'attachment',
  15. 'numberposts' => -1,
  16. 'post_status' => null,
  17. 'post_parent' => $post->ID,
  18. 'post__not_in' => array( get_post_thumbnail_id() ),
  19. 'post_mime_type'=> 'image',
  20. 'orderby' => 'menu_order',
  21. 'order' => 'ASC'
  22. ) );
  23. if ($attachments) {
  24. $loop = 0;
  25. $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 3 );
  26. foreach ( $attachments as $key => $attachment ) {
  27. if ( get_post_meta( $attachment->ID, '_woocommerce_exclude_image', true ) == 1 )
  28. continue;
  29. $classes = array( 'zoom' );
  30. if ( $loop == 0 || $loop % $columns == 0 )
  31. $classes[] = 'first';
  32. if ( ( $loop + 1 ) % $columns == 0 )
  33. $classes[] = 'last';
  34. printf( '<a href="%s" title="%s" rel="thumbnails" class="%s">%s</a>', wp_get_attachment_url( $attachment->ID ), esc_attr( $attachment->post_title ), implode(' ', $classes), wp_get_attachment_image( $attachment->ID, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) ) );
  35. $loop++;
  36. }
  37. }
  38. ?></div>