Restricting image sizes and resizing on upload
Hi
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?
thanks
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);