Loope Recent Items only if they are images

Hello, I'd like to use the recent items function to loop through only the most recent images.
Right now, I'm using this...

<div id="recent-items">
    		<h2>Recently Added Items</h2>

    		<?php set_items_for_loop(recent_items(8)); ?>
    		<?php if (has_items_for_loop()): ?>

    		<div class="items-list">
    			<?php while (loop_items()): ?>

    			<div class="item">

    				<?php if(item_has_thumbnail()): ?>
        				<div class="item-img">
        				<?php echo link_to_item(item_square_thumbnail()); ?>
        				</div>
    				<?php endif; ?>

    			</div>
    			<?php endwhile; ?>
    		</div>

    		<?php else: ?>
    			<p>No recent items available.</p>

    		<?php endif; ?>

    		<p class="view-items-link-home"><a href="<?php echo uri('items'); ?>">View All Items</a></p>

		</div>

This generally works except when any of the recent items are non-images (PDFs, etc) in which cae, I'm just left with the empty div I used in my stylesheet.

------------

Okay, actually I found the answer before I finished posting to I'll just put it here in case anyone is looking for the same thing!

take the code above but use this...

<?php set_items_for_loop(get_items(array('recent' => true,'type' => 'Image'),8));?>

instead of this...

<?php // set_items_for_loop(recent_items(8)); ?>

If you have items are not of item type Image, but have image files that you want to display, you could test for a thumbnail before adding the item dive. So you could alter you code as follows:

<div class="items-list">
	<?php while (loop_items()): ?>
		<?php if (item_has_thumbnail()): ?>
			<div class="item">
				<div class="item-img">
				<?php echo link_to_item(item_square_thumbnail()); ?>
				</div>
			</div>
		<?php endif; ?>
	<?php endwhile; ?>
</div>

Thanks Will. As you pointed out, my code above unnecessarily limits the returned items to those with the Image item type. As such I modified it to pre-test for the thumbnail image regardless of item type, and found the following loop to work best for my needs...

<div id="recent-items">
    		<h2>Recently Added Items</h2>

    		<?php set_items_for_loop(get_items(array('recent' => true,'item_has_thumbnail'=>true),8));?>

    		<?php if (has_items_for_loop()): ?>

    		<div class="items-list">
    			<?php while (loop_items()): ?>

    			<div class="item">

    				<?php if(item_has_thumbnail()): ?>
        				<div class="item-img">
        				<?php echo link_to_item(item_square_thumbnail()); ?>
        				</div>
    				<?php endif; ?>

    			</div>
    			<?php endwhile; ?>
    		</div>

    		<?php else: ?>
    			<p>No recent items available.</p>

    		<?php endif; ?>

    		<p class="view-items-link-home"><a href="<?php echo uri('items'); ?>">View All Items</a></p>

		</div><!--end recent-items -->

I noticed my code wasn't working right, so I came back and I see that Will was right, not surprisingly. Thanks.

Okay, this is still not working quite right. In the code below, I'm calling for the 20 most recent items that have thumbnail images attached. Instead, I am getting the 20 most recent, including those without thumbnails (currently, three recent items have no image), which leaves three blank spaces in the returned loop. So the question is: am I doing this wrong, or is Omeka not acting as expected?

<!-- Recent Items  -->
		<div id="recent-items">
    		<h2>Recently Added Items</h2>

    		<?php set_items_for_loop(get_items(array('recent' => true,'item_has_thumbnail' => true),20));?>

    		<?php if (has_items_for_loop()): ?>

<div class="items-list">
	<?php while (loop_items()): ?>
		<?php if (item_has_thumbnail()): ?>
			<div class="item">
				<div class="item-img">
				<?php echo link_to_item(item_square_thumbnail(array('alt'=>item('Dublin Core', 'Title')))); ?>
				</div>
			</div>
		<?php endif; ?>
	<?php endwhile; ?>
</div>

    		<?php else: ?>
    			<p>No recent items available.</p>

    		<?php endif; ?>

    		<p class="view-items-link-home"><a href="<?php echo uri('items'); ?>">View All Items</a></p>

		</div><!--end recent-items -->

Any help would be greatly appreciated.

Thanks,

Erin