Workaround for Transparent PNG Thumbnails in SharePoint Image Libraries

christineAdministrator Guides, SharePointLeave a Comment

PNG files with transparency display the transparent bits as black instead of transparent in SharePoint image libraries. Since it’s been this way for years now, it’s unlikely Microsoft will fix the issue. Here’s a hacky workaround for when you really need it (like… when you have an icon library with black icons with transparent backgrounds).

sharepoint transparent png

This is a smartphone icon, can’t you tell?

Step 1 – Create Two Plain Text Columns

I like to call one LibURL and the other ImageURL. For LibURL, set the default to the URL of the library (sans forms/view.aspx) with no trailing slash (e.g. https://whatever.sharepoint.com/sites/sitename/libraryname).

Step 2 – Create a Workflow

I’m assuming you’re passably familiar with SharePoint workflows, if not head to Youtube and search for a beginner guide to SP2013 workflow. Create a list workflow on your image library and add the action “set field in current item” and tell it to set the ImageURL field to “Server-Relative URL”. Have it run when items are modified or created, and publish.

Step 3 – Create a Calculated Column

This calculated column will create the HTML needed to display our transparent thumbnails. This is the jankiest part, as it relies on the fact that calculated “number” columns in SharePoint render HTML. You could also set this with workflow instead (into a rich text column) if you’re worried about the reliance on a quirk, but calculated columns are kinda nifty. Set your data type to “number.” If you used the same column names as I did, your formula will be the following:

=CONCATENATE("<a href=",CHAR(34),[LibURL],[ImageURL],CHAR(34),"><img style=",CHAR(34),"max-width:80px;",CHAR(34)," src=",CHAR(34),[ImageURL],CHAR(34)," /></a>")

Step 4 – Fix your View

Image libraries default to the out-of-box thumbnail view. They should also create a second view called “all items” – this is a more typical list view. Head over to that view (or create a list view), enable your thumbnail column (the calculated one), move it to the first position, hide the image type icon (because it’s not super helpful), and try it out! Your new custom thumbnail should like to the full-size version of the image.

sharepoint custom png

Leave a Reply

Your email address will not be published. Required fields are marked *