Greetings all.
I am trying to use and display custom XMP metadata within zenphoto. My image files have a catalog of additional data that basically should be displayed on the image page and possibly change some of its behaviour.
I got this prepared as an XMP sidecar file. Now this file is analyzed by the xmpMetadata plugin as a filter, setting some of the values it recognizes and ignoring everything else. I would like to have the whole $metadata object from this filter available to my theme.
Which is the cleanest way to get this running without breaking anything else? I was thinking to do something like
$image->set('xmpMetadata', $metadata) in the plugin, but I am not even sure whether the $image object is available in image.php afterwards.
Thanks in advance for any pointers,
Thomas
Comments
I have no further detailed knowledge of this plugin so I guess you need to wait until my collegue sbillard responds later.
You will see that the current plugin attaches several filters to do its tasks. When these filters are invoked, the object for which they are invoked is passed as a parameter. So you just accumulate your custom fields and store them in the passed object custom data field.
Thus, the fields would be created by setup.php, turn up in the image options and search options, and be available for writing from xmpMetadata.php using $image.set() (even though I decided to populate my database directly now).
Any drawbacks to this approach I may have missed?
---
Thanks for your answers. I found the easiest way to add my custom fields to add them to the exif data table in functions.php in a custom namespace.
Thus, the fields would be created by setup.php, turn up in the image options and search options, and be available for writing from xmpMetadata.php using $image.set() (even though I decided to populate my database directly now).
Any drawbacks to this approach I may have missed?
That is clearly explained right below the form when you are posting and on the forum rules as well.
Hacking core files is always troublesome. You will have to readd your fix with every update and it may not even work with future releases. It might be possible to write a exif reader for your purpose (see zp-core/exif). Maybe it could even be done via a plugin. Bbut I am not familiar with that exif stuff. My collegue sbillard is a way a few days but will surley be able to tell more when he returns. Expect that beginning next week.
re clearly explained: I wasn't exactly expecting the older posts to disappear from the thread during moderation of the last one.
I think it could be a great idea to officially support custom extensions to the EXIF/IPTC data structure in the core. At least with the XMP format, arbitrary tags and namespaces for metadata can be added, while not everyone will be interested in all possible other tags - I think it could easily become a generic 'metadata' list, creating those columns in the database that you select, and removing those that you choose to ignore.
That would probably require to have the setup.php script around until you have made a final selection for your gallery.
Yeah, sorry for the confusion, indeed, the plugin for our forum we use can'T differ already approved posts by new users from unapproved. It just marks a certain number of first posts no matter what.
You may want to create a ticket for this idea so it does not get lost on the forum. Sbillard will tell if this is something we consider or not then.
Unfortuanately the EXIF handling scripts are pretty much spaghetti code and are not easily extended. If the code already will detect and capture your fields it may be simply a matter of adding them to the table of correspondence that is established by the setexifvars() function. If not, good luck.
If you choose to extend these routines, let us know. If the change is of general use we will incorporate your code.