Wednesday, March 15, 2017

Exposing SharePoint Picture Library Thumbnail and Web Optimized Images

Introduction



The SharePoint picture library has some built in functions that can be very handy for usage in other areas of SharePoint.  Every image that is added to the library gets two versions created that are hidden from the end user.  One is a web optimized jpg image.  The other is a thumbnail image.


SharePoint uses these images for its own purposes, the web optimized images are used in publishing sites, and the thumbnails allow the picture library to have thumbnail based views.  The picture library is a useful tool for managing and exposing pictures.  By extracting the web optimized and thumbnail paths of these images, we can then use those paths for our own purposes where we need either the thumbnail or web optimized version.


This post shows how to pull the "hidden" paths to the images through a workflow and expose them for your own use.




Create a Picture Library



If you haven't created one already, you will need to first start with a SharePoint picture library.  These are available by default on Publishing sites, and on other sites where the "Team Collaboration" list feature is used.




You may have to deactivate and then reactivate this feature to get the picture library to show up.  Use "Site settings" -> "Add an App" and search for the picture library to find the icon below.


Add the picture library to your site.



Add two new fields to the Image Library



We need to fields to hold the image paths within our picture library.  Create two new columns, plain text.  One called WebImageURL.  And one called ThumbnailImageURL.





Create a Workflow to Populate Fields



Now that we have the fields available, we can populate them using a workflow.  Create a new workflow in SharePoint bound to this picture library.


Create a new "Action" step, "Set field in current item".  Choose "ThumbnailImageURL" as the field, and select "Current Item - Thumbnail URL" as the value:




Repeat the step for the web image url, setting field to WebImageURL and value to current item, Web Image URL.  Notice that the built in fields have spaces in their names. We are copying the info in those built in workflow fields over to our own fields to expose them.


One you are done your workflow should look like this:




Set this workflow to run automatically whenever an item is created.


Now, when you add an item to this list, the additional fields you created now expose the paths to the optimized images:



These paths can now be copied and pasted anywhere within SharePoint to use the optimized versions of the images.

No comments:

Post a Comment