How to exclude pdf from lightbox slideshow

Would anyone have a suggestion how I can exclude pdf's from showing in the lightbox? I have tried to implement the suggestions from http://omeka.org/forums/topic/lightbox-pdf-files-omeka-12, but to no avail. I am unsure why in the examples 'file' and '$file' is used, where as 'item' is used in 'my' code. Simple replacing doesn't do the trick...

The code I have now show one thumbnail to start a slideshow. The slideshow tries to upload the pdf, which is already uploaded in Docsviewer at the bottom of the page. I don't want nor need it on the item page twice.

The code I have at the moment is:

<div id="itemfiles" class="element">
	    <h3>Files</h3>
		<div class="element-text">
		    <?php
		    if (item_has_thumbnail())
					{
					echo '<p><em>Click thumbnail for full size images</em></p>';
					$file = loop_files_for_item();
					echo display_file($file, array('linkAttributes' => array('rel' => 'lightbox[gallery]')));
					while($file = loop_files_for_item()):
   					echo display_file($file, array('linkAttributes' => array('rel' => 'lightbox[gallery]', 'class' => 'hiddenfile')));
endwhile;}
			else
				{
				echo display_files_for_item();
				}
			?>
		</div>
	</div>

See http://arpc65.arm.ac.uk/omeka/items/show/564369 for an example. Here I have a few sample pages that will show up in the slideshow, and the entire file in docsviewer.

Any suggestions on how to change the above code to exclude pdfs would be greatly appreciated!

Adding a simple check inside your while loop should do the trick. This check will only include files with thumbnails (so, images), in the lightbox gallery.

while($file = loop_files_for_item()):
    if ($file->has_derivative_image):
        echo display_file($file, array('linkAttributes' => array('rel' => 'lightbox[gallery]', 'class' => 'hiddenfile')));
    endif;
endwhile;

Brilliant! Thanks, John!

Given that thumbnails are created for PDF files now, is there a way to exclude a PDF from lightbox based on file type?

Thanks!