Pages (2): 1 2   
Member
Member
the_voder   18-11-2013, 16:29
#1

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

Administrator
Administrator
acrylian   18-11-2013, 16:53
#2

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

Member
Member
the_voder   19-11-2013, 11:50
#3

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

Administrator
Administrator
acrylian   19-11-2013, 12:13
#4

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.

Member
Member
the_voder   19-11-2013, 12:57
#5

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

Administrator
Administrator
acrylian   19-11-2013, 13:05
#6

Sure, I understand. You could use jQuery for example to change the name printed before the custom data field as well to "mimic" your purpose. But that would of course also require a plugin using a filter.

Member
Member
the_voder   19-11-2013, 13:12
#7

That would probably work OK, actually. So can a plugin inject CSS and JavaScript scripts into the ZenPhoto backend, then?

a|x

Administrator
Administrator
acrylian   19-11-2013, 13:52
#8

Yes, see the plugin architecture article I linked above.

Member
Member
sbillard   19-11-2013, 18:48
#9

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.

Member
Member
the_voder   20-11-2013, 12:34
#10

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

Administrator
Administrator
acrylian   20-11-2013, 13:24
#11

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.

Member
Member
the_voder   20-11-2013, 14:14
#12

I see. I completely understand about this being a volunteer project. Was just wondering…

Thanks, guys,

a|x

Administrator
Administrator
acrylian   20-11-2013, 15:00
#13

Sure, was just an explaination. I think the best for your purpose is probably to use a filter plugin.

Member
Member
the_voder   20-11-2013, 15:38
#14

@acrylian a filter plugin to inject jQuery code and tweak the admin DOM, you mean?

a|x

Administrator
Administrator
acrylian   20-11-2013, 16:59
#15

Actually not really as the custom data field especially has only a class on the input element but not on the name before it. It is currently not even a label.

Member
Member
the_voder   20-11-2013, 17:49
#16

@acrylian I noticed that. Thought I might be able to select it using a jQuery 'td:contains()' selector.

a|x

Administrator
Administrator
acrylian   20-11-2013, 17:56
#17

Yes, but the problem is there are a lot "td" on the edit pages. You could use the "nth-child" selector but that of course will not work on some (older) browsers like especially IEs. But if that is no isssue that would be a way.

Member
Member
the_voder   22-11-2013, 16:05
#18

@acrylian you're right. It's harder than I thought to target the relevant DOM element…

a|x

Member
Member
the_voder   28-11-2013, 16:28
#19

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

Administrator
Administrator
acrylian   28-11-2013, 16:52
#20

Did not check in detail but couldn't you get the children right away with the first jquery call?

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.