Hello Kind readers…
Recently I came
across an interesting finding that helped me realize how Publishing image
libraries can help in taking care of performance when lots of LARGE size images
are been used in a portal (which could be a very common scenario )
May be this is
something commonly known already but I stumbled upon this now and thought of
sharing it on my space.
A Little background : -
publishing image libraries host pictures and when you upload a picture
SharePoint by default creates a Thumbnail
and Web Image(preview image) for the original image. Now these two version
are stored in respective folders
Now, I believe this
much is something almost all everyone is aware of and could easily found on the
internet, yes true, BUT what I couldn’t find easily was the default values and
ways of calculation for these image versions which lead me to look into it more
My Findings: -
If you dig into the
PictureLibrary feature folder in 14 directory and tried to open the schema….
WAIT.. Before that if you casually browse the MSDN for the properties of SPDocumentLibrary class, you will find MANY properties :) but our focus for now are three specific properties
As the description
for each say, these properties are used to decide what would be the size of the
web image and thumbnail image.
Now if you go back
to the Picture Library feature folder we opened before and this time look
inside the library schema, you will see that by default SP has set these values
160 (height width
Now lets take an
example , suppose I upload an image with Width X Height = 1024 X 768
Now since the width
here is more than default that is so the calculation is
original height /
original width x new width = new height
1200 / 1600 X 640 =
Like wise all sizes
are compared for web images based on given values and for thumbnail both height
width are same which is 160px. (ASPECT RATIO IS
Now how does it
help, it helps when you want to have more efficient specific sizes for
been get and set both gives you the flexibility
- To update them through code
- Include custom value in
custom list template
This makes more
sense when you know that you will be having webparts on pages that will not be
needing a image that would be bigger than suppose 260px to display.
Does not make sense
to load the whole image which could be 1024px wide and using CSS you compress
it to 260px, this will not only distort the look but also does not save the performance as it anyways is loading the full
To come over this
you decide to use the preview image (web image) version created by SP default
stored in the hidden _w directory of the
image library, this still is not very great because by default that will create
a 640px wide image.
To save the
performance you can set the library WebImageWidth to 260px and next time
whenever a new image is uploaded the preview version of it will be created with
width defaulting to 260px and height will be adjusted accordingly with
calculations to maintain aspect ratio, thus you save performance points here
when there is huge media content.
The web images (_w) are like 4-5 times smaller in size than
original images which I take to be a GREAT performance boost.
The same is true for
thumbnails so you can decide the default values for thumbnails as per your need
helping in a bit more help in performance.
One of the best part
about this is that these properties ARE
Available in sandbox / office 365 solutions so it helps you improve
performance there if needed.
It does make sense
in my current requirement so I can say this can come in handy at lot many
If you want to
explore (which I did but m not going to write a lot on it, will leave for you
to explore :) ) then do explore the IMGLIB.js
found in /_layouts/1033 folder, there is
some interesting stuff you find helpful for images in SharePoint.
One very helpful
This function will
very easily return the required image url without you having to do lot of
string tampering, so you just need to pass orignal image URL … servername/site/list/images/image.jpg and _t if you want thumbnail or _w if you want web image and then returned URL
you can directly use in your
or whatever logic.
information is helpful to someone…