1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Extending Library Module with thumbnail support for tif, bmp, ...

Extending Library Module with thumbnail support for tif, bmp, ...

4 posts, 0 answered
  1. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    08 Mar 2010
    Link to this post
    The library module (custom library) supports all file types but not the corresponding thumbnail.

    The problem is that the original uploaded file should not be changed, so it can be downloaded in its original type. For the purpose of a better overview a thumbnail should be available in all Controls (admin and public).

    Now I’m thinking of creating a custom handler for thumbnail generation, than overwrite a method in the controls (like LibraryListView, LibraryItemPreview, etc.) to set the new image url. Which method would that be?
    Could that functionality be achieved that way?
    Or is there a way to automatically generate and save a thumbnail to an uploaded file without converting the original file? So that way I wouldn't have to modify the controls.

    Thanks,
    Mat
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    08 Mar 2010
    Link to this post
    Hi Mat,

    The thumbnail is generated when a file is being uploaded. To get around this you need to create a custom module, because the place where we generate a Thumbnail cannot be accessed. We use ImagesHelper.GenerateThumbnail method in UploadFile method of LibraryManager class. GenerateThumbnail is static so you cannot override it.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    09 Mar 2010
    Link to this post

    Hi Ivan,
    Thanks for the quick response.

    I created a custom provider MyLibraries and overwrote SaveContent as following.

    if (content.Thumbnails.Count == 0)
           {
               //Custom Helper
               ImageHelper img = new ImageHelper((byte[])content.Content, ImageFormat.Jpeg);
               byte[] b = img.GetThumbnail();
                         
               Telerik.Cms.Engine.IThumbnail it = this.AddThumbnail(content, b, "image/jpeg", ".jpg", "16640015", true);
               this.SaveThumbnail(it);               
           }
           base.SaveContent(content);

    (I know the name of the file in AddThumbnail is hard coded)

    Now in the list (LibraryListView) the thumbnail still doesn’t show. When I manually request the url “…/MyLibraries/LibraryName/16640015.tmb.ashx?width=70&height=70&decreaseOnly=true” the thumbnail still returns as tif image although it was saved as jpg.

    What am I missing?
    Is it even possible that way?

    Thanks,
    Mat

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Mar 2010
    Link to this post
    Hello Mat,

    I will get back to you in the support request you have opened.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered