Help with Custom Taxonomy
-
Hi, again,
I’m trying to figure out how to map terms in a taxonomy from incoming XMP data. I now can retrieve the XMP fields correctly, thanks.
In a (I suspect related) post to this forum, you instruct to “scroll down to the Taxonomy term mapping section” on the IPTC/EXIF tab. However, I don’t see such a section, just “Add New Custom Field Rule”. I don’t seem to be able to enclose a screenshot.I’m assuming taxonomies have to be created beforehand, with another plugin. Is this correct? Do I also have to have all the taxonomy terms pre-created, or can the mapping do that (I hope)?
What about hierarchical taxonomies? Is there any way I can map into those from the xmp fields? Suppose I have set up a taxonomy “genre”, and two terms, genre->night->astro in a hierarchy. If I set my xmp IntellectualGenre field to “astro” on the image, would a rule mapping genre -> {+xmp.Iptc4xmpCore.IntellectualGenre+} do the right thing?
-
Follow up: I figured out that my new taxonomies show up in the list box on the right-hand column under the IPTC/EXIF tab, so I could edit the rule there.
And running the rule does create new terms, as desired.
However, it misses hierarchical terms, and assigns them as top level terms.
Is there a workaround for this? Is there a way I can tag the original image to preserve hierarchy in taxonomies?
Thanks!!
Good to hear from you again. Thanks for the questions and the research/experimenting you’ve been doing to find your own answers.
As you discovered, the layout and content of the Settings/Media Library Assistant IPTC/EXIF tab has changed significantly (v2.60) since the earlier topic was written. The new layout is much more “WordPress-like” and it works more like all the other tabs.
Regarding hierarchical taxonomies, you have a few options. As you’ve seen, new terms are added automatically. You can select a parent term for them on the “Edit Rule: Taxonomy term mapping” screen, but you cannot identify a more complex hierarchy for terms being added for the first time. There is no standard way to identify term hierarchy in the IPTC and EXIF standards and I haven’t looked in detail at specific XMP implementations.
However, if you do pre-define your terms, MLA will match terms in the incoming images and assign the existing terms to your item(s), including their proper place in the hierarchy. In the WordPress philosophy, hierarchical taxonomies such as “categories” are meant to be more deliberate and stable, and flat taxonomies such as “tags” are considered more ad-hoc and informal.
I hope that gives you the information you need to design your application and taxonomies. I am marking this topic resolved, but please update it if you have any problems or further questions regarding mapping your metadata to taxonomy terms.
Well, actually it didn’t match terms in the incoming images to a predefined hierarchical term; it created the same term at the top level, assigning it a different slug. Specifically, I had created the genre taxonomy, a top-level term called “night” and a child term of night called “astrophotography”. The incoming image was tagged with “astrophotography” for the genre. MLA created the top-level “astrophotography” term. I executed the rule from the dashboard, not on image upload, although I wouldn’t imagine that would make a difference. So this seems like a bug to me.
What would be interesting would be able to define a path, like night/astrophotography in the xmp metadata, and have that match to the nested child term. That way, I could have the same term appear in different hierarchies.
- This reply was modified 7 years ago by wesm.
Thanks for your update. In my testing earlier today the existing term match worked properly. If you could post your mapping rule details and a link to the image you tried I will investigate further. You wrote “I executed the rule from the dashboard; can you tell me the steps you followed in more detail?
I appreciate your suggestion for a “path” definition. I don’t think it’s appropriate for the core MLA logic because it’s too application specific. It might be possible to implement as a small custom “example” plugin. Would that be of interest?
Here is the mapping, in the EXIF/Template Value field of the Edit Rule dialog:
template:([+xmp:Iptc4xmpCore.IntellectualGenre+])It’s the same image as earlier, here, and the caption dump technique shows a genre of astrophotography.
When I list my “Genre” taxonomy on the dashboard, I see terms:
Name Slug
astrophotography astrophotography-2
Night night
— Astro Photography astrophotographyThe first one in the list shouldn’t be there, it wasn’t before I executed the rule, which I did by clicking the “Execute” link under the rule in the rule table.
As far as proper scope, I note that Attachment Category is a hierarchical taxonomy ??
Thanks for the additional information. In fact, I think I see cause of the problem you experienced.
You created a term named “Astro Photography”, but you imported a term named “astrophotography”. Since those two values do not match, a new term was created.
The mapping rules operate on the term name/title, not the term slug, because the source metadata contains the display names of the keywords/terms. As your example indicates, the slug values are modified by WordPress to ensure uniqueness and there’s no reliable way to use them to match with incoming metadata values.
Regarding “proper scope”, my comments are about the format and syntax of the “path” values, e.g., using “night/astrophotography” to denote parent/child relations. Does that make sense?
Ah, OK, Thanks. So I should use the title, i.e., the “friendly name” for the term, not the slug. I used the slug because I read elsewhere that that was what WP used for matching, but I don’t recall if it was taxonomy, custom fields, or what.
Do you mention this fact in the doc somewhere? Possible I missed it, but the doc is huge (and sort of dense).
I see there is a delimiters field in the Taxonomy term mapping. I assume that is so you can specify multiple terms, e.g., “night,urban”. My suggestion about the path was that you introduce an optional path delimiter for hierarchical terms. Of course, that would complicate the database query, not so nice for doing tree- or graph-based searches.
Thanks for your additional comments. The use of slug and title/Name for taxonomy terms can be confusing. Once WordPress has created a term using the slug is appropriate because it uniquely identifies a term-taxonomy combination in the WordPress database. To create the slug, WordPress will start from the Name and then “sanitize” it and modify it to make it unique.
When adding metadata to image files there’s no good way to know in advance what the WordPress slug will be and the “Keywords” values in the IPTC/EXIF standard are intended to be the “friendly” Name values. That’s why I decided to use Name instead of slug for matching incoming values.
This is not mentioned in the MLA Documentation tab. As you have observed, the Documentation is large and dense and still doesn’t do justice to some of the subject matter. I went back to the IPTC/EXIF Mapping sections and couldn’t decide on an appropriate way to add the material. I welcome any suggestions you have on how to present it there.
You wrote “I see there is a delimiters field in the Taxonomy term mapping.” Yes, it is there because different programs use different delimiters to separate multiple Keywords/terms. All of the standards documentation I have found considers Keywords to be “flat”, i.e., no hierarchy. The standards exist to make it easy to share images among different organizations and applications. Adding a path delimiter would make it hard for other applications to use your Keywords, but that’s not a problem if you have no intention of sharing your images. I will see if there’s a feasible way to add this feature to MLA.
I have uploaded a new MLA Development Version dated 20180124 that contains a solution for the “path delimiter for hierarchical terms“. I have implemented this feature as an example plugin to avoid complicating the core MLA code.
The example plugin has a Settings screen with a Documentation tab that explains how to use it.
To get the Development Version, click this link to download the Development Version ZIP archive:
https://downloads.www.ads-software.com/plugin/media-library-assistant.zip
Once you have the ZIP archive on your system:
- Login to your site’s Admin area and navigate to Plugins/Installed Plugins.
- Find Media Library Assistant and deactivate it.
- Find Media Library Assistant and delete it. You will not lose any settings.
- Go to Plugins/Add New.
- Click “Upload Plugin”, to the right of the Add Plugins title.<br>”Browse…” to the location of the ZIP Archive and click on it.
- Click “Install Now”, to the right of “Browse…”
- When the install completes, click “Activate Plugin” at the bottom of the screen.
- When the activation completes, go back to the Plugins/Installed Plugins screen.
- Scroll down to “Media Library Assistant” and look for a date like “20180124” at the start of the Description. That’s how you know you have a Development Version. You can also go to the Settings/Media Library Assistant submenu and see the date stamp in the heading.
That’s it. I don’t change the version number of the Development Version, so you will be notified when the next official version comes out and the normal update process will continue to work.
To install the example plugin, navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. You will see a table that lists all the example plugins and gives you a “one-click” action for installing them. Type “path mapping” in the text box (including the quotes) and click “Search Plugins” to filter the table. You are looking for “MLA Path Mapping Example” example plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate it as you would any other plugin.
Let me know if you have any problems with the above suggestions and if you have a chance to try out the new example plugin. Thanks for inspiring an interesting addition to the example plugin library!
- The topic ‘Help with Custom Taxonomy’ is closed to new replies.