title: Wordpress img alt text
body: <p>I'm looking to print out the alt text for each thumbnail image on this page <a href="http://www.venaproducts.com/dev/product/fosmon-hybo-duoc-case-for-amazon-fire-phone/" rel="nofollow">http://www.venaproducts.com/dev/product/fosmon-hybo-duoc-case-for-amazon-fire-phone/</a> </p>
  
  <p>However the first image alt text seems to be used for ALL thumbnail images even though the alt text are different. Any help is much appreciated.</p>
  
  <pre><code>global $post, $product, $woocommerce;
  
  $attachment_ids = $product-&gt;get_gallery_attachment_ids();
  
  if ( $attachment_ids ) {
  ?&gt;
  &lt;div id="product-images" class="thumbnails"&gt;&lt;?php
      $small_img   = wp_get_attachment_image_src(get_post_thumbnail_id(),'single-product-thumbnail');
      $middle_img  = wp_get_attachment_image_src(get_post_thumbnail_id(),'single-product');
      $large_img   = wp_get_attachment_image_src(get_post_thumbnail_id(),'single-product-zoom');
      $img_id = get_post_thumbnail_id(get_the_id());
      $alt_text = get_post_meta($img_id, '_wp_attachment_image_alt', true);
  
  
      echo '&lt;a href="#" data-image="' . $middle_img[0] . '" data-zoom-image="' . $large_img[0] . '"&gt;
                &lt;img src="' . $small_img[0] . '" alt="' . $alt_text . '"&gt;
            &lt;/a&gt;';
      $loop = 0;
      $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 3 );
  
      foreach ( $attachment_ids as $attachment_id ) {
  
          $classes = array( 'zoom' );
  
          if ( $loop == 0 || $loop % $columns == 0 )
              $classes[] = 'first';
  
          if ( ( $loop + 1 ) % $columns == 0 )
              $classes[] = 'last';
  
          $image_link = wp_get_attachment_url( $attachment_id );
  
          if ( ! $image_link )
              continue;
  
          // $image       = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) );
          // $image_class = esc_attr( implode( ' ', $classes ) );
          // $image_title = esc_attr( get_the_title( $attachment_id ) );
          $small_img = wp_get_attachment_image_src( $attachment_id, 'single-product-thumbnail' );
          $middle_img = wp_get_attachment_image_src( $attachment_id, 'single-product' );
          $large_img = wp_get_attachment_image_src( $attachment_id, 'single-product-zoom' );
  
          // echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '&lt;a href="%s" class="%s" title="%s"  rel="prettyPhoto[product-gallery]"&gt;%s&lt;/a&gt;', $image_link, $image_class, $image_title, $image ), $attachment_id, $post-&gt;ID, $image_class );
          echo '&lt;a href="#" data-image="' . $middle_img[0] . '" data-zoom-image="' . $large_img[0] . '"&gt;
                    &lt;img src="' . $small_img[0] . '" alt="' . $alt_text . '"&gt;
                &lt;/a&gt;';
  
          $loop++;
      }
  
  ?&gt;&lt;/div&gt;
  &lt;div class="carousel-prev product-prev"&gt;&lt;/div&gt;
  &lt;div class="carousel-next product-next"&gt;&lt;/div&gt;
  &lt;?php
  </code></pre>
  
  <p>}</p>