function test for "public"

I have a custom script that grabs images related to items. If any of the items are "private", the whole simple page will break. Is there a conditional test I can wrap around the code the prevent this? Something like "if item is public, then...output the file..."

Assuming you are digging up the Item object, this should do the trick

if(metadata($item, 'public') == 1) {
echo 'public'; //or whatever display
}