title: Woocommerce Displaying Products With Product Images
body: <p>I have a wordpress site running the wordpress plugin WooCommerce. Because of the sheer volume of products this site is handling we have been managing the product list outside of the site and uploading it. A lot of the products don't have images yet but they have a hard coded image url so we can add them when we get them. To get around broken images I just do a little search for the image size and if I can't find it and replace it with a placeholder.</p>
  
  <pre><code>$src = wp_get_attachment_image_src( get_post_thumbnail_id($post-&gt;ID), $size);
  if (@getimagesize($src[0])) {
      //display product image
  } else {
      //display placeholder image
  }
  </code></pre>
  
  <p>This is working fine in most cases but now I am working on displaying the products in a category. I want to display all the products with images first and then display the products without images. The problem is once the loop starts if I exclude products without images it will loop through the first 12 products and only display a subset of the 12 that have images. What I want it to do is keep looping until I have 12 products with images (if there are 12 products with images).</p>
  
  <p>This is what I have right now that doesn't work.</p>
  
  <pre><code>&lt;?php if ( have_posts() ) : ?&gt;
      &lt;ul class="products"&gt;
          &lt;?php while ( have_posts() ) : the_post(); ?&gt;
              &lt;?php 
                  $src = wp_get_attachment_image_src( get_post_thumbnail_id($post-&gt;ID), $size);
                  if (@getimagesize($src[0])) {
                      woocommerce_get_template_part( 'content', 'product' );
                  }
              ?&gt;
          &lt;?php endwhile; // end of the loop. ?&gt;
      &lt;/ul&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>Possible logical solutions that I have been unable to code would be to ignore some product while in the loop (so it would make another run if there is no image) or somehow code my query as part of the requirement of the loop i.e. pit it in the $args?</p>
  
  <p>Any help would be greatly appreciated.</p>