More in this section

Forums / General Discussions / Restricting image sizes and resizing on upload

Restricting image sizes and resizing on upload

2 posts, 0 answered
  1. Nick
    Nick avatar
    113 posts
    21 Oct 2008
    08 Feb 2013
    Link to this post


    What's the current best way to manage users who insist on uploading massive images?

    I know that each library can have it's own restrictions on file size and pixel dimensions, but inevitably a user will create new library and not know to, not care about, or intentional avoid, setting these correctly, and then they'll be free to upload whatever they want.

    Is there any global settings that can be applied that would restrict/resize uploads to a maximum pixel size?


  2. Randy Hodge
    Randy Hodge avatar
    96 posts
    03 Nov 2014
    13 Feb 2013
    Link to this post
    Hello Nick,

    Thank you for contacting us.

    Currently, there is no way to set a global maximum for images being uploaded. To achieve that you would need to create a custom DataProvider, which serves as an intermediary between programmatic CRUD operations and the database.

    Basically, you need to create a new provider and inherit from the default LibrariesDataProvider. Then you can override the UploadImage method to include your custom logic. Make sure to set the ResizeOnUpload property to false such as:
    using System;
    using System.Linq;
    using Telerik.Sitefinity.Modules.Libraries.Data;
    namespace SitefinityWebApp
        public class LDPC : OpenAccessLibrariesProvider
            protected override void UploadImage(Telerik.Sitefinity.Libraries.Model.Image image, System.IO.Stream source, string mimeType)
                image.Album.ResizeOnUpload = false;
                //custom resize logic ...
                base.UploadImage(image, source, mimeType);

    For more information on how to substitute the default libraries provider with your custom one once you've implemented and built the class you can check this blog post, I hope you find it useful.

    All the best,
    Randy Hodge
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered