Tuesday, March 21, 2017

How to create thumbnail/preview of any document or Image or Video in SharePoint

Hi Friends,

In this post, we are going to learn how to generate a thumbnail/preview of any Document or Video or Image in SharePoint.

Recently I came across a requirement to show some document links on a page but the links should be the thumbnail of the document instead of a plain text(document title). Please find the below approach I followed to achieve this.

getpreview.ashx is a http handler used to generate thumbnail/preview of any document(word,pdf, ppt etc.,), Image and Video which resides in SharePoint.

If you observe in SharePoint search results, when we mouse over on the search results we get a preview of that item. This is actually happening through http handler getpreview.ashx

This handler expects a parameter called “path” which expects absolute path of the doc/image/video. Please find the below sample URLs to generate the thumbnail.

Image:

Document:

Video:

This handler has also expects a parameter called “resolution” which has a predefined values 1, 2, 3 etc., for different resolutions of previews/Thumbnails. Please find the below sample URLs with different resolutions



Hope this helps…

Wednesday, March 15, 2017

How to use Image Renditions in SharePoint

Hi Friends,
In this post we are going to learn What are the Image Renditions and how we can use it in SharePoint.

Image renditions helps to display a single image into various sizes based on our needs. Apart from choosing size, it also allows you to crop the image while adding it to the publishing page.

So based on our needs, we can display abcd.jpg as Logo, Banner and Thumbnail etc., This technique helps in reducing the size of the file that is downloaded to the client, which then improves site performance. You can find some of the ways to improve SharePoint site speed and performance here.

The other advantage if you notice, we need not to create different sized images i.e., one for logo, one for thumbnail etc.,. With Image renditions we can display a single image into multiple sizes.

Below are the prerequisites for using Image Renditions 
  •  Publishing Site
  • BLOB Caching enabled(Follow this link on how to configure BLOB cache and its uses)



Please find the below steps on how we can configure Image Renditions.

1.     Go to the top-level site of the publishing site collection.

2.    Choose the Settings icon. On the Site Settings page, in the Look and Feel section,  choose Image Renditions.

3.    This will show you list of available Image Renditions available on this site. We can  modify the existing one, Or we can even create our own based on required dimensions.



          4.       ID indicates the RenditionID. We will be using this RenditionID as a parameter to                       specify the dimensions of an image we need.

         5.       If we want to construct image URL directly from the RenditionID, we just need to                  add it as a  Query String.

Examples: If we want display abcd.jpg as 100*100 on a page, then my image source URL will be “abcd.jpg?RenditionID=1
If we want display abcd.jpg as 200*200 on a page, then my imgage source URL will be “abcd.jpg?RenditionID=2”

        6.       If we want to insert the image in the page content then follow the below steps. 
a)     Edit the page and place the cursor in the Page Content field.

b)    From the Ribbon Insert tab, choose Picture, and then choose From    SharePoint.

c)     Select the image that you want to add to the page and then choose Insert. The image will be displayed at full size.

d)    Next on the Design tab, in the Select group, choose Pick Rendition, and then select an  image rendition whichever required. That’s it, the image will display according to the size  specified for the image rendition.

Hope this helps... 

Tuesday, March 14, 2017

What is a BLOB cache in SharePoint and how to use it?

Hi Friends,

In this article, we are going to learn what is a BLOB cache and how to configure it.

The term BLOB means Binary Large Objects. BLOB cache is one of the disk-based caching techniques used in the SharePoint applications which has large amounts of Media content (Video, Audio and Images etc.,) and heavy user traffic.

So basically this method is used to improve the performance of a SharePoint Application. You can also find some of the other SharePoint performance improvement techniques here.

Disk-based caching techniques are extremely fast which eliminates the need for database round trips. BLOBs are retrieved from the database once and stored on the Web client(WFE server). Further requests are served from the cache and trimmed based on security.

Note: If you are using Image Renditions in the application, then BLOB Cache is the pre-requisite.

We can enable/disable the BLOB cache by modifying the web.config file of the SharePoint web application.
By Default, BLOB cache is disabled. Below is how it looks like.

<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="false" />

- Location is the directory where the cached files will be stored.
- Path specifies which files(Ex: mov|mp3|mp4|mpeg|mpg) are cached based on the file extension.
- maxSize is the maximum allowable size of the disk-based cache in gigabytes.

- enabled is a Boolean that disables or enables the cache.

To turn ON the BLOB, just make the property enabled as true as shown below.

<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="true" />

Note : change the location attribute to specify a directory that has enough space to accommodate the cache size.


Hope this helps...

Popular Posts