• Resolved pgill11

    (@pgill11)


    I doubt that this is possible, but I need to ask…

    Each of the images I’m importing has one of the following sets of xmp:Iptc4xmpExt properties:

    • LocationShownCountryName
    • LocationShownCountryName AND LocationShownProvinceState
    • LocationShownCountryName AND LocationShownProvinceState AND LocationShownCity

    I’d like for MLA to create (if necessary) and attach the appropriate number of hierarchical categories each time an image is imported.

    For example, if an image has

    • LocationShownCountryName=”United States”
    • LocationShownProvinceState=”New York”

    Can MLA create two categories

    • United States
    • United States/New York

    and attach the category “United States/New York” to the image?

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

    (@dglingren)

    Thanks for an interesting question and for outlining your application goal. There is no support in the MLA core code for this type of mapping but it could be accomplished with a custom plugin that uses the hooks MLA provides. Your specific question is a variation on this old support topic:

    Lightroom Hierarchical Subject XMP | www.remarpro.com

    The example plugin developed for that topic is included in the MLA “Example Plugins”. You can access it by navigating to the Settings/Media Library Assistant Documentation tab, clicking the “Example Plugins” button and entering “Hierarchical” in the search box.

    It should be feasible to expand that example to handle your application. The examples you gave in your post are somewhat different from those in the “IPTC Photo Metadata Reference Image”. The Reference Image shows an array of two location elements:

    xmp:Iptc4xmpExt.LocationShown.0.City => City (Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.CountryCode => R22
    xmp:Iptc4xmpExt.LocationShown.0.CountryName => CountryName (Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.LocationId.0 => Location Id 1a(Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.LocationId.1 => Location Id 1b(Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.LocationName => Location Name (Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.ProvinceState => Province/State (Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.Sublocation => Sublocation (Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.WorldRegion => Worldregion (Location shown1) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.0.GPSAltitude => 140/1
    xmp:Iptc4xmpExt.LocationShown.0.GPSLatitude => 48,8.82N
    xmp:Iptc4xmpExt.LocationShown.0.GPSLongitude => 17,5.88E
    xmp:Iptc4xmpExt.LocationShown.1.City => City (Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.CountryCode => R22
    xmp:Iptc4xmpExt.LocationShown.1.CountryName => CountryName (Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.LocationId.0 => Location Id 2a(Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.LocationId.1 => Location Id 2b(Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.LocationName => Location Name (Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.ProvinceState => Province/State (Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.Sublocation => Sublocation (Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.WorldRegion => Worldregion (Location shown2) (ref2022.1)
    xmp:Iptc4xmpExt.LocationShown.1.GPSAltitude => 120/1
    xmp:Iptc4xmpExt.LocationShown.1.GPSLatitude => 47,57.12N
    xmp:Iptc4xmpExt.LocationShown.1.GPSLongitude => 16,49.8E

    As you can see, there’s no “LocationShownCountryName” element. It would be very helpful if you could post a link to one or more of your images so I can verify the exact format of the location metadata. You could instead contact me at my web site?and send one or more images by email.

    I will leave this topic unresolved and I hope to hear more from you; any additional details or test images would be helpful. Thanks for your interest in MLA.

    Thread Starter pgill11

    (@pgill11)

    Just sent my contact info.

    BTW I’m using the reverse geocoding feature in Camera Bits’ Photo Mechanic to populate the 3 XMP properties.

    Thread Starter pgill11

    (@pgill11)

    Kudos
    Please let me say, one programmer to another, that it’s been a pleasure working with your code. It’s well written and structured. And has an impressive level of functionality.

    The Problem
    My goal is to import three location metadata values created by the Reverse Geocoding feature in Photo Mechanic 6. The location needs to be imported into WP categories using the following hierarchy: country / state / city.

    The Solution
    There are two parts to the solution.

    1. The MLA EXIF/Template Value needs to be set to: template:[+iptc:country-or-primary-location-name+](\|[+iptc:province-or-state+])(\|[+iptc:city+])
    2. line 98 in mla-hierarchical-mapping-example.php needs to be changed
      • from: if ( false !== strpos( $rule[‘exif_value’], ‘[+xmp:lr.hierarchicalSubject+]’ ) ) {
      • to: if ($rule[‘hierarchical’] && $rule[‘active’] && (0 < strlen($rule[‘exif_value’]))) {

    Conclusion
    I believe that you could merge this example code into the production plugin for full-time use by the Att. Categories rule.

    There is only one Att. Categories rule which means we can import only one <span style=”text-decoration: underline;”>type</span> of category. In my case that’s a location. In the original plugin that’s getting a subject from the Lightroom hierarchicalSubject. It’d be nice to be able to create additional taxonomy term mapping rules.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for working with me by email to complete the updates to the example plugin. Your idea to use a template to compose a value from individual location parts is a good one. I made a change in part 2 of your solution so the updated plugin handles the original Lightroom hierarchical subject case and any taxonomy terms template containing literal vertical bars, e.g., the template in part 1 of your solution.

    I have uploaded a new MLA Development Version dated 20230524 that includes the updated example plugin. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    Once the Development Version is installed you must install (or update) and activate the example plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “hierarchical” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA Hierarchical Mapping Example” plugin. Find that plugin and hover over the title in the left-most column. Click the “Install” (or “update”) rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate the example plugin as you would any other plugin. Make sure you have the latest version, 1.02, installed.

    Once the Development Version and updated example plugin are installed and active you can test its handling of your IPTC Country|State|City mapping rule.

    This example plugin will be part of my next MLA version, but in the interim it would be great if you could install the Development Version and the example plugin and let me know if it works for you. Thanks for inspiring this MLA improvement.

    Plugin Author David Lingren

    (@dglingren)

    I have released MLA v3.09, which contains the updated example plugin for this topic. I am marking this topic resolved, but please update it if you have any problems with this latest update. Thanks for your interest in the plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can MLA create hierarchical location categories?’ is closed to new replies.