Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #27291
    Profile photo of Terry Hale
    Terry Hale

    Hi Robin,

    We talked a bit about this a while back. I’m trying to figure out a way to automatically assign images to a category based on what is in the EXIF data for the image. I’ve been looking around at the code in tool-ftp.php and I found the following code:

    if (isset($metadata->SupplementalCategories)) {
        if (!is_array($metadata->SupplementalCategories)) $category[] = $metadata->SupplementalCategory;
        else $category = array_merge($metadata->SupplementalCategories,$category);
    if (isset($metadata->SupplementalCategory)) {
        if (!is_array($metadata->SupplementalCategory)) $category[] = $metadata->SupplementalCategory;
        else $category = array_merge($metadata->SupplementalCategory,$category);

    My client is using a Sony camera along with Photoshop Elements to modify the EXIF data. The two data pieces that are available in regards to category are “Category” and “SuppCategory”. Interestingly, both of those, along with “Supplimental Categories” were deprecated when IPTC Core 1.0 (XMP) was released. Which is a bit disappointing from a marketplace standpoint.

    Anyway, I figured out from the code that that category ID should be used in those fields (rather than the slug, for example). Using the “Exif Pilot” app, I updated the “Category” and “SuppCategory” fields to reflect the WordPress category ID. So I added the following code above what was existing already in tools-ftp.php:

    /* #custom */
    if (isset($metadata->Category)) {
        if (!is_array($metadata->Category)) $category[] = $metadata->Category;
        else $category = array_merge($metadata->Category,$category);
    if (isset($metadata->SuppCategory)) {
        if (!is_array($metadata->SuppCategory)) $category[] = $metadata->SuppCategory;
        else $category = array_merge($metadata->SuppCategory,$category);
    /* /#custom */

    That did not work either.

    Is there another place within the Symbio Pro plugin that tries to extract category info and assign it?

    Profile photo of Robin

    What you have done should work fine as far as I can tell. Symbiostock uses the wp_set_object_terms function which can accept both slugs and IDs. So if you are adding the WooCommerce category IDs to those meta fields (Category or SuppCategory) the system should be trying to add them.

    Are you certain metadata reading is working in general? This sort of advanced stuff would require Exiftool to be running, which means in your settings > System tab exec functions must be enabled.

    Profile photo of Terry Hale
    Terry Hale

    All metadata had been importing successfully (ie, everything in Diagnostics checked out), but recently it stopped working.

    Honestly, I don’t know what setting I changed back, but now the code above is pulling in the Category and assigning the images to the correct category ID in WordPress.  And keywords are translating to tags, etc.

    Thanks for your continued positive feedback and support. 🙂


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.