Adding new fields to metadata

I would like to add new fields to the metadata section at Albums->Images.

I have read on the forums about a workaround, but no one goes into greater detail.

What I want is to add fields where City, Location, Copyright exist. I understand that the data comes from the image, but I want the user to be able to add their content so that it is searchable.

how can I do that without augmenting the core files?

Comments

  • This can be done, but would probably require "participation" by other users of the custom data field. Since we do not really know what plugins might use the field there is some risk, but at least for a local install the risk is mangeable.

    The general technique is to store multiple fields in an array with the array index of the field being then name of the field. That array is serialized when stored in the custom data database field and unserialized when you want to use the data. There is a filter `save_image_custom_data` that you would attach to copllect and serialize the data for storage and one `edit_image_custom_data` to format the admin page data input.

    The `comment_form` plugin would be a good example of this technique. It saves the user's address, etc in the user object custom data field. The filters here are of course for `admin` not `image` but the mechanism is the same.
  • acrylian Administrator, Developer
    As mentioned on the ticket, you don't need to store arrays in the custom data field. You should be able also use the filters mention to keep the custom data plain as it is and add new fields using the `plugin_storage` table. That will be a bit more of work since you need to "tie" these fields to the item.
  • okay, so let's say I want to go the route of creating new fields in the metadata section using the "plugin_storage" table in the database.

    Please tell me how I would go about doing that? What pages in your code would I need to change?

    I am competent with using PHP and MySQL and I know that queries are going to need to be written, but I want to safeguard that anything I touch won't get wiped out with an upgrade of your product.

    I have already successfully created a new theme for my purposes with your product, so this last little bit would be extremely useful to get my last project finished.
  • acrylian Administrator, Developer
    You will need to use the right filters and the object model:
    http://www.zenphoto.org/news/zenphoto-plugin-architecture#zenphoto-filters
    http://www.zenphoto.org/news/zenphotos-object-model-framework

    Here is a demp plugin that splits teh custom field into several fields:
    https://github.com/zenphoto/Unsupported/tree/master/plugins/filter-custom_data
    Instead splitting you need to return it plain and the additional input fields that then are stored in the plugin_ storage table.

    Info about all database tables on the admin overview pages. There is also a pdf in your install under /docs that shows the rough interactions between the tables
Sign In or Register to comment.