Hi guys
I'm super new to PHP, so bear with me! But I have a super simple code here that will display all images in a folder, and print the 'header' IPTC metadata and then print the filename. My query is this -- it currently repeats the last available IPTC header, even if the next image doesn't have any metadata stored in it. So how can I tell the code to simply not print anything at all if the IPTC data isn't stored in the file?
Thanks a lot
James (here's the code)
<?php
$files = glob("*.*");
for ($i=0; $i<count($files); $i++) {
$image = $files[$i];
echo '<img src="'.$image .'" title="'.$image .'" alt="'.$image .'" width="5%"/>'."<br />";
$picinfo = array();
getimagesize($image, $picinfo);
if(isset($picinfo['APP13']))
{
$iptc = iptcparse($picinfo["APP13"]);
}
if (is_array($iptc)) {
$description = $iptc['2#105'][0]; /* IPTC 'Header' metadata */
}
print_r($description);
print "<br />"; print $image ."<br /><br />"; /* Print filename */
}
?>