I'm really stuck with this one, so if someone has a little time to help me on this...

What i want :

I have a pictures library in a site. It is even a PublishingImages library. a lot of my images are .PNG files. So, i want to display a thumbnail of these files along with the name and every property i could get.

What i have :

Because these are PNG files with transparent background (and a lot of time, they are white icons), Sharepoint does not generate a good thumbnail and this last turn out to be all white. So, it is not helping.

What i thought :

I understood that SP is not good with calculating PNG thumbnails and that my PNG files are converted to JPG etc.. but i would like it to render fine, ok?

So, i thought i would create a new Content Type Column, which should be a html calculated column, with a formula which takes the original path of the file and add it a rendition.

So, instead of having only "Name" and "Thumbnails", i would have "Name", "Thumbnail", "Custom Thumbnail" as columns. And in Custom Thumbnials, i should have a formula which says concat(ImageURL,'?RenditionID=9') for example.

Do you know how i could manage to calculate my custom column on one other ? Do you know how i could manage to do that ?

Thanks a lot for your time and help !!

  • You may use FileRef, FileLeafRef columns to get the ImageURL and than append the rendition.. Did you try creating a Calculated Column? – Arsalan Adam Khatri Oct 8 '15 at 15:13
  • Hi Arsalan, I tried to create a Calculated column, but the only columns i could add to the Formula are Author, Copyright, Created, height, title and so on.. no url nor file's path in it... Do you have any idea on that ? thanks to remind me of FileLeafRef, i'll see if i can use it. – Gaelle Oct 8 '15 at 15:31

One way is to add a new Hyperlink or Picture column to the library and set its value using sharepoint desginer workflow every time a new picture is added. For existing pictures you can use powershell script to set the value of this field. SharePoint creates 2 thumbnail urls for each uploaded image


| improve this answer | |
  • Thanks Harry, i am currently trying to set a workflow. So, do you have an idea on which column do i have to use to retrieve the url of my image? And, i am working on SP Online, so i can't execute a Powershell script for that. – Gaelle Oct 8 '15 at 15:13
  • you will need to create a workflow variable to type string and constuct the url. for example. sitename/PublishingImages/_w/…. You can also use JSLink to create a custom view. JSLink will give you access to much more infomation about the image file. – HarryB Oct 8 '15 at 15:20
  • You can construct the URL using the image file name in a SP designer WF variable. For SP Online you can use CSOM (Javascript/C#) to update properties for existing images. – HarryB Oct 8 '15 at 15:48

only simple types like Text, Date and Number can be used in Calculated Columns

The information you are after exists in the Page in JavaScript Object ctx.ListData.Row

If you set a Calculated Column to datatype=Number it can execute HTML/Javacript

Explained at: http://www.viewmaster365.com/#/How

This Formula:

="<img style=""width:80px;height:80px;background-color:blue;"" "
&"src=""/_layouts/images/blank.gif"" onload=""{"
  &"var TR=this;while(TR.tagName!='TR'){TR=TR.parentNode}"
  &"var item=ctx.ListData.Row[TR.rowIndex-1];"
  • Executes JavaScript (with a blank.gif onload trick because Microsoft blocked the SCRIPT tag)
  • gets the correct FileRef from the ctx.ListData.Row object
  • sets the onload to false otherwise it would trigger again when it
  • replaces the blank IMG with your (PNG) image.
    You can apply all your CSS skills on that IMG

answer scoring appreciated

I left the console.log in so you can get after other info you want, there is a lot of info in there.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.