This blog will show you how programmatically activate SharePoint document libraries for SharePoint Premium Image Tagging with PowerShell. This developer focused blog will provide the necessary PowerShell commands to add the special column Image Tags to a library with the property IsEnhancedImageTaggingEnabled set to TRUE. By doing so the library is then activated for Image Tagging. Uploaded images are then auto scanned with AI then tagged with descriptive keywords with no training or manual tagging required.

Previous Blog: Microsoft Syntex Image Tagging – Leon Armston’s Blog

The special field Image Tags (Internal Name: MediaServiceImageTags) seems to be just a special taxonomy field. That appears to be linked to a hidden term group and term set in your tenant’s term store. This term set will contain all the terms that are used to tag images & you cannot access it directly/at all.

I will now show you below how you can using PowerShell activate a library for image tagging.

Script Required

Activate a library for SharePoint Premium Image Tagging

To activate a library for Image tagging the site firs needs to be enabled for SharePoint Premium Image Tagging. Then a admin user needs to browse to the library and enable the library for Image Tagging. This is completed by going to the Automate section of the document library bar then selecting Configure Image Tagger. A popout menu will then appear to “Enable image tagger on this library” – you will then click Enable. That’s all the configuration needed!!

This image has an empty alt attribute; its file name is image-5.png
How SharePoint Premium Image Tagging is enabled in the UI

Below are the a small section of the field properties for the Image Tags field in two libraries in two seperate SharePoint Premium Image Tagging enabled tenants. You can see they share the same GUIDs for AnchorId, TermSetId & TextField. However the SspID value is different as each tenant has it’s own term store (SspId is the termstore ID).

I then realised adding the special Image Tags field to a library activated it for Image tagging. A special SchemaXml needs to be used for creating the field which I’ve figured out – just needs changing the SspId to your Termstore ID. The termstore ID is unique to your tenant.

Note: I think all that needs to be changed between tenants is the SspId but I’ve only been able to test on UK M365 tenants. Different regions/languages may use different IDs perhaps. So you may need to inspect the SchemaXml of an existing Image Tags column to check the IDs used.

Below is a script which is uses PnP PowerShell to add a Image Tags column to a library which then activates the library for Image Tagging. Change lines 1 & 2 to reflect the details of your environment.

This script connects to the site/list you specify. Obtains your tenant level SspID (TermStore ID) and adds it to an xml variable containing the SchemaXml of an Image Tagging column. This is then used with Add-PnPFieldFromXml which create a special Image Tags Taxonomy field in the library using the modified SchemaXml. The library is then enabled for Image Tagging.

There are then two extra steps in the script which I always like to add when I use Image Tagging.

  • Add the Image Tags (MediaServiceImageTags) column to the default library view
  • Add a Thumbnail image column which then shows a preview of the uploaded image.

Below is a library that was enabled using PowerShell for SharePoint Premium Image Tagging. The Image Tags column along with a newly created Thumbnail column are added to the default view.

Disable SharePoint Premium Image Tagging in a Library

You may also wish to programmatically disable a library from using Image Tagging. The script below will do this – change lines 1 & 2 to reflect your site/library details. This script then updates the field property IsEnhancedImageTaggingEnabled to be FALSE.

Summary

SharePoint Premium Image Tagging is a great feature and enables images to be scanned with AI andtagged with descriptive keywords. The PowerShell scripts show you how to programmatically enable a library for Image Tagging along with the reverse – disabling Image Tagging.

Some suggestions for programmatically enabling Image Tagging.

  • Provision an “Images” library with Image Tagging turned on in every provisioned site as part of your site provisioning solution.
  • Add a library called provisioning to each existing “Project” site and enable it for Image tagging.

Image tagging is incredibly useful and as images are uploaded they are then tagged with descriptive keywords. Users can then search, filter on these values – saving users time opening lots of images to view them.

It appears SharePoint Premium uses quite a few special Termstore columns i.e. for Taxonomy Tagger. Take a look at my previous blog which shows you how to deploy Taxonomy Tagger columns at scale. – The Ultimate Guide to Adding SharePoint Premium Taxonomy Tagging Columns Programmatically.

Let me know how you are using SharePoint Premium Image Tagging and whether you have any questions or feedback. Happy to help!

Leave a Reply