This is a migrated thread and some comments may be shown as answers.

Replacing thumbnail functionality

2 Answers 41 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Balint
Top achievements
Rank 1
Balint asked on 24 Aug 2012, 02:25 PM
Hello guys,

Really love the FileExplorer, but I'd like to tinker with the Thumbnails functionality. In its current state the thumbnail is just a link to the original image. Since I use the FileExplorer control to serve up a gallery of hi-res stock images, my page basically downloads twenty-megabyte JPEGs as "thumbnails". This also results in ugly compression artifacts and distortions as the browser uses its own algorithm to compress the image.

Is there any way to override the thumbnail display functionality either on the client side or on the server side? For example, if I could point the thumbnails to an ASP.NET handler instead of the images themselves I'd be all set to go since I could perform my own high-quality resizing on the server side and serve up small, good quality thumbnails.

Any ideas?

2 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 29 Aug 2012, 10:04 AM
Hi Balint,

In order to achieve the desired functionality you should implement a custom FileBrowserContentProvider. Then you have to change the behavior of the ResolveDirectory method as the easiest way to do this is to subclass the default provider (Telerik.Web.UI.Widgets.FileSystemContentProvider)  and override that method only.

For example, you could use your own compression algorithm  in order to create the thumbnails and then to set the file's URL to the desired thumbnail in the overwritten method. The specific thing here is that the default content provider does not set URLs and when you implement it every image will be a link to its thumbnail but not to itself.

This could be workarounded with the following handler, attached to the OnClientFileOpen event, which will bring back the original paths to the images:
<telerik:RadFileExplorer ID="FileExplorer1" runat="server" OnClientFileOpen="explorerFileOpen">
    <Configuration ViewPaths="~/Images" UploadPaths="~/Images" />
</telerik:RadFileExplorer>
 
<script type="text/javascript">
    function explorerFileOpen(explorer, args) {
        args.get_item().set_url(args.get_item().get_path());
    }
</script>

Following a similar logic, you could also overwrite the StoreFile method, associating a thumbnail to every new image which is being uploaded.

Greetings,
Veselina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Balint
Top achievements
Rank 1
answered on 10 Sep 2012, 08:18 AM
Thanks Veselina, this did the trick!
Tags
FileExplorer
Asked by
Balint
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Balint
Top achievements
Rank 1
Share this question
or