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

Forums / Developing with Sitefinity / Max Height/Width on Library Images

Max Height/Width on Library Images

2 posts, 0 answered
  1. Damon
    Damon avatar
    6 posts
    Registered:
    27 Jan 2009
    27 Jan 2009
    Link to this post
    We are using the built in library to manage images and was wondering if there is there a way to disallow the user from uploading images that exceed a specific max height and max width that we can set somewhere (preferably in the web.config file)?

    I was looking at the built in user control located at : /Sitefinity/Admin/ControlTemplates/Library/ControlPanelEdit_Image.ascx and was thinking one way to achieve this is by adding range validators on the page that provide the restrictions. However this would be modifying the built in controls. Is there a better way to achieve this?

    Thanks!
    Damon
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 Jan 2009
    Link to this post
    Hello Damon,

    Thank you for using our services.

    You can set Max library size and through Sitefinity interface for a given library. Restricting the size could be done a handler:

    object obj = temp.GetMetaData("Width"); 
    if(obj !=null
    width = Convert.ToInt64(obj); 
     
    obj = temp.GetMetaData("Height"); 
    if(obj !=null
    height = Convert.ToInt64(obj); 
     
    if (width > 100 || height > 100) 
    // add your logic here 
     
    temp.SetMetaData("Width", img.Width); 
    temp.SetMetaData("Height", img.Height); 
     
    .... 
    .... 
    libraryManager.SaveContent(temp, ContentStatus.Published); 

    You can find the following link useful http://www.sitefinity.com/help/developer-manual/libraries-extending-module.html

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered