Is it theoretically possible to create a plugin to change the photo meta-information fields visible when a photo is viewed or edited in backend of a ZenPhoto site?
I'm trying to ensure that certain fields are highlighted to indicate that they Must be filled in, and, if possible, that non-essential fields are hidden altogether, but I'd rather do this with a plugin, that hack around the ZenPhoto core files.
This kind of thing is achieved in the Wordpress world using custom post types, so was wondering if it something equivalent was possible in Zenphoto.
Cheers,
a|x
What meta fields do you mean? I assume you mean the `` meta tags and not the image meta data (EXIF/IPTC).
Zenphoto does not have fields for these html meta tags. The html_meta_tags plugin does generated the entries automatically via the content that is there (like tags, titles, descriptions).
Acually on WP I would not use custom post types but the post_meta table to create extra fields for meta data. Zenphoto has a similar general table called plugin_storage you can use for the purpose of extra fields.
This table has no API since there is no "fixed" usage as it can be used for anything. So you need to use it with queries. ZP has a bunch sql related functions (http://www.zenphoto.org/documentation/core/_functions-db-MySQL.php.html#functionquery_full_array).
To create the fields you can use the image_custom_data filters. You basically have to pass through the standard custom field and add your custom ones from the plugin_storage table.
http://www.zenphoto.org/news/zenphoto-plugin-architecture#media
Hi acrylic, thanks very much for the explanation.
I think we may be talking slightly at cross-purposes. When I said 'meta', I really just meant the information that gets saved for each image, rather than the HTML meta tags of the page displaying the image.
Do you happen to know of any existing plugins that add fields to or customise the look of the image data form (not sure of the terminology here, but I think you know what I mean)? I really just want to add a 'Photographer' field, and make sure it is visible by default, rather than the user having to click the 'Show more fields' link.
a|x
Ok, my advice above is the same anyway regardles if html meta or just image extra fields. You can use the custom data field filter or one of the utility or general box on the right to add extra fields. There is an example plugin for the custom data and the multiple_layouts plugin for example uses a utility box filter as does the tweet_news plugin.
You could also just use the custom data field for the "photographer". The front end does not really care how the field on the backend is named, it is a general purpose field.
I see. I'll have a look at the the plugins you mention.
I realise that the custom data field could be used, but I wanted to make it a bit more intuitive, and make it obvious that this field was required. I'm making an image library for an online journalism project, and the library will be used by a large number of students, or widely varying levels of technical competence and inclinations to read documentation, so I want to make things as simple as possible.
Thanks again,
a|x
The closest plugin we have is the unsupported disableAction plugin. You might look at that for a start. Basically you need to implement some javascript to "edit" the DOM of the page and make the highlighting you want.
The example plugin disables the field, but you should be able to add a highlight instead.
You can find the plugin on GitHub in the "unsupported" repository.
Hi sbillard,
thanks for the tip- I'll have a look!
Incidentally, I read somewhere on the forum about a possible backend rewrite. Would that maybe include steps to make targeting items like the field in question with JavaScript/jQuery easier i.e. by adding more specific classes, IDs or data attributes to form items?
Cheers,
a|x
A html/css cleanup is planned for next year, hopefully for 1.4.7: https://github.com/zenphoto/zenphoto/issues/191
Yes, that would include some more classes to address items more specifially. In this case just proper form element labels would help…
However, that's quite a major task and since we are volunteers you need to have the time for it which is quite an issue. Since it involves a lot backend functions and other stuff you sadly cannot just partly start but have to constantly work on it.
This seems to work:
$("td:contains('Custom data')").filter(function() {
return (
$(this).clone() //clone the element
.children() //select all the children
.remove() //remove all the children
.end() //again go back to selected element
.filter(":contains('Custom data')").length > 0)
})
as a selector. I'm sure it's a massively inefficient way to do it, though.
a|x