Support » Plugin: Media Library Assistant » Att. Categories Advanced Mapping

  • Resolved kartguru


    Hi David

    As previously mentioned its enjoyable reading through various questions and the support you provide. I’ve solved a few problems here but am struggling to find a topic discussing my issue. I see solutions in the gallery display (frontend) but not in backend mapping functionality. It could be my basic understanding of WordPress and not knowing the specific terminology to use. I do apologise if this is the case.

    Anyway I’m using the Simple Location plugin. It’s reverse geocoding the coordinates and producing a ‘geo_address’. Using the MLA’s IPTC & EXIF mapping I can insert the 3 levels(?) at the same Att. Category level but not in the intended hierarchy (which is Country > Region > City).

    An example. from is processed by Simple Location as “Horsley, Northumberland, United Kingdom”. In the reverse order of the location I’d like to add to Att Categories as ‘United Kingdom > Northumberland > Horsley’.

    Is my above scenario possible with MLA?

    Thanks for taking the time to read and I look forward to your response. I really do appreciate any assistance you can give even if quite small.

    – michael

    Note. I’m hoping learnings from and the ,extract(p,v) functionality can assist me in doing this. I am yet to test but feel its doable.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author David Lingren


    Thanks for your question and for the reference to the Simple Location plugin. Thanks as well for digging through the Documentation and finding the ,extract(p,v) option/format value, which is a part of the answer.

    I installed and activated the Simple Location plugin on my system and ran some tests, which gave a solution for your application.

    You can use MLA’s regular expression option/format values and one of the MLA Example Plugins to accomplish your task. The regular expression values let you parse the geo_address value into its component parts and re-arrange them.

    For your application, this content template should do the job:

    template:[+custom:geo_address,extract('/(?<city>[^, ]*), (?<region>[^,]*), (?<country>.*)/')+](/[+matches:country+]/[+matches:region+]/[+matches:city+])

    The template accesses the custom:geo_address field that contains values such as your example, “Horsley, Northumberland, United Kingdom”. The extract pattern parses it into three individual fields; city, region and country. The final portion, (/[+matches:country+]/[+matches:region+]/[+matches:city+]), assembles the three-term hierarchical path you need to populate the taxonomy terms. The parentheses around this portion will bypass any values that do not contain all three levels.

    The “MLA Path Mapping Example” plugin lets you specify a complete, multi-level path for adding hierarchical term relationships to a taxonomy. The example plugin has a Settings screen with a Documentation tab that explains how to use it. In particular, the settings let you decide on which parts of the hierarchiy to assign to each item.

    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” 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.

    Once the example plugin is active you can define a mapping rule to create and assign the geo_address terms:

    1. Go to the Settings/Media Library Assistant IPTC/EXIF tab.
    2. If you want to apply the rule to new items as they are uploaded, check the “Enable IPTC/EXIF Mapping when adding new media” and “Enable IPTC/EXIF Mapping when updating media metadata” boxes.
    3. Locate the “Att. Categories” rule entry in the table and click the “Edit” rollover action.
    4. In the “IPTC Value” dropdown control leave the default “- None (select a value) -” in place.
    5. In the “EXIF/Template Value” text box enter the Content Template given above.
    6. In the “Priority” dropdown, select “EXIF”.
    7. In the “Existing Text” dropdown, select “Replace” to replace existing term assignments or “Keep” to add the terms generated by the rule to any existing assignments.
    8. Scroll down to the bottom of the screen and click “Update”.

    Once you define a rule you can apply it to a single item, multiple items or all items:

    • To map a single item, go to the Media/Assistant submenu and click the thumbnail of the item you want (or click the “Edit” rollover action) to get the Media/Edit Media screen. You can click the “Map IPTC/EXIF metadata” link to run your rules on this item, then scroll down and look at the “Att. Categories” meta box to inspect the results.
    • To map two or more items, go to the Media/Assistant submenu and click the checkbox next to the items you want. Then, select “Edit” from the “Bulk Actions” dropdown above the checkboxes and click “Apply” to open the Bulk Edit area. Click the “Map IPTC/EXIF metadata” button to run your rules on the selected items.
    • To map all of your items, stay on the Settings/Media Library Assistant IPTC/EXIF tab and click the “Execute” rollover action for the App. Categories rule. This may take a while.

    I hope you can combine the example plugin with the regular expression option/format parameters to get the results you seek. I will leave this topic unresolved for now in case you have problems or further questions regarding the above suggestions. Thanks for your interest in MLA.

    Thread Starter kartguru



    I am slightly embarrassed as I did look at the first page only of the example plugins and snippets of their documentation. I did not realise there are 72 example plugins to extend what is a massive plugin already. Can I blame young children and sleepless nights?

    Hats off mate, I don’t even know what else to say. I hope your family understands the contribution you’ve made with this plugin. For me, I had started a project almost 2 years ago and a few failed attempts to get the results described above had me wondering if I would ever get it live. With your plugin I now think its a real possibility.

    Anyway even if I found the plugin I think I may have needed a little help after a few failed attempts. I followed the above detailed instructions (with explanations) and I was able to replicate the described (and desired) outcome.

    I do truly thank you David and hope you have a wonderful retirement!

    – michael

    Thread Starter kartguru


    One additional update for those wishing to follow these instructions.

    When executed from Media Library Assistant Settings > IPTC & EXIF Processing Options > Att. Categories rule, it worked as described.

    When run from Media/Assistant submenus (or set to run on upload) it created unwanted categories. Changing the default ‘Option’ in the rule to Text (from array) resolved the issue.

    Plugin Author David Lingren


    Thanks for the good news on your progress and for the kind words. Yes, my spouse is very supportive and the plugin keeps me engaged with the WordPress community in retirement.

    Thanks as well for catching my omission of the “Option: Text” setting in my rule creation steps. I used that setting in my own rule but missed it in preparing the instructions.

    I will leave this topic resolved, but please update it if you have any other problems or questions with the template or mapping rule.

    Thread Starter kartguru


    If I may a quick update to assist others David. To check all in the hierarchy I update the template to …

    template:[+custom:geo_address,extract('/(?<city>[^, ]*), (?<region>[^,]*), (?<country>.*)/')+](/[+matches:country+]/[+matches:region+]/[+matches:city+]), (/[+matches:country+]/[+matches:region+]),(/[+matches:country+])


    – michael

    Plugin Author David Lingren


    Thanks for your update with the additional template pieces.

    An alternative solution would be to navigate to the Settings/MLA Path Mapping General tab and checking the “Assign parent terms” option setting. This option automatically assigns all the terms in the path when the lowest-level term is assigned. In your application the option would automatically assign region and country when city is assigned.

    Thread Starter kartguru


    Of course you already had a solution for this 😉 Great stuff!

    Thanks and take care David

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Att. Categories Advanced Mapping’ is closed to new replies.