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
Comments
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
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
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 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
a|x
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.
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
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.
Thanks, guys,
a|x
a|x
a|x
a|x
$("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
do you mean?
$("td:contains('Custom data')")
Unfortunately, that returns all the elements containing 'Custom data', including the parent elements of the tds I want to get.
a|x
http://api.jquery.com/nth-child-selector/
I mean the number of <td> and even <tr> is known so it should be possible to get the nth tr with the nth td within to change the value.
the problem is the tables containing the items I want to select are also not uniquely identified, so if I use nth:child I may end up selecting items in other backend tabs or panels.
a|x
$("table[id|='image'] tbody tr:nth-child(n)").hide();
where n is the row number. It's complicated by the fact that some of the rows of the containing table for the data for each image contain further tables, but the method above does appear to work.
a|x