Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: Developing with Sitefinity > Extending Library Module with thumbnail support for tif, bmp, ...

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

  • Mat avatar

    Posted on Mar 8, 2010 (permalink)

    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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Mar 8, 2010 (permalink)

    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.

    Reply

  • Mat avatar

    Posted on Mar 9, 2010 (permalink)

    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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Mar 12, 2010 (permalink)

    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.

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: Developing with Sitefinity > Extending Library Module with thumbnail support for tif, bmp, ...