How is printImageMetadata() supposed to work?

I've checked the forum and read the function description in the User Guide. I'm trying to figure out how to not display any of the exif titles for photos that don't have exif information.

I tried using the following code in my theme's image.php file:

`printImageMetadata('', false, 'imagemetadata_inline', '', false, '', 'No EXIF information available.');`

However, it displays the exif categories, Camera Model, etc, even when a photo doesn't have exif information. Using the function call above, shouldn't the function print "No EXIF information available" when a photo doesn't have exif information?

Or, is there another way to test if the exif info is blank?

Thanks!

Comments

  • `getMetadata()` will return `false` if there is no metadata in the image. It there is metadata it will return an array of that data which you could check to see if there is anything of interest.

    Generally speaking, the `printXXX` functions will always output something, is if you wish sometimes not to have output you need to use the equivalent `getXXX` function to test first.
  • Hmm, I'm using the following code, but it still prints exif fields even when the image says "None selected for display" under Metadata in the Zenphoto Admin.

    `

    if (getImageMetaData())

    {

    printImageMetadata('', false, 'imagemetadata_inline', '', false, '', 'No EXIF information available.');

    }

    `
  • Ah, got it working using info in this thread regarding getMetadata()...

    http://www.zenphoto.org/support/topic.php?id=4786#post-28148
  • acrylian Administrator, Developer
    Well, sbillard already mentioned `getMetaData()` above...;-)
  • Yes he did. :-) I had a hard time finding a list of the exif field names though...is that located in the user guide somewhere?
  • There is no 'static' list. The list is based on the `$_zp_exifvars` array at the front of functions.php. What gets shown by `printImageMetadata()` is based on the 'display' element of each metadata field. That field defaults to the value in `$_zp_exifvars`, but is changable via the options tabs.

    So, if you want to know if any exif data will be displayed you have to test each element with `display` set to `true` and see if it is not empty.
  • Thanks for pointing out functions.php, that's the list of array elements I was looking for!
Sign In or Register to comment.