Jump to content

JamesWood

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by JamesWood

  1. Ahh I figured it out with an 'if else' statement Just wasn't sure how to phrase it correctly, but it's working now. <?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 (empty($picinfo["APP13"])) { $description = ""; } else { $description = $iptc['2#105'][0]; /* IPTC 'Header' metadata */ print_r($description); print "<br />"; } print $image ."<br /><br />"; /* Print filename */ } ?>
  2. 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 */ } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.