Thumbnails
- 2 minutes to read
Image Thumbnails
ASPxFileManager automatically creates thumbnails for image files with the following file extensions:
- bmp
- gif
- ico
- jpg
- jpeg
- png
For better performance, these content-based thumbnails are stored in the location specified by the FileManagerSettings.ThumbnailFolder property.
Note
The folder that contains thumbnails must be placed inside the application folder.
Default Thumbnails
ASPxFileManager includes default thumbnails for the file types listed below.
File Extension | Default Thumbnail |
---|---|
txt | |
rtf doc docx odt | |
xls xlsx ods | |
ppt pptx odp | |
Other extensions, where thumbnails are not defined |
Use the FileManagerImages.File property to change the thumbnail for a file.
Custom Thumbnails
In addition to automatically created and default thumbnails, ASPxFileManager allows you to make custom thumbnails available to users by handling the ASPxFileManager.CustomThumbnail server event. This event allows you to define whether all files or certain files should be displayed in folders. Within the event handler, use the FileManagerThumbnailCreateEventArgs.Item property to access and identify the currently processed item. To define a custom thumbnail for the file, use the FileManagerThumbnailCreateEventArgs.ThumbnailImage property.
In the example below, the CustomThumbnail event is handled to analyze file extensions and represent each file type using the corresponding custom thumbnail image.
public void ASPxFileManager1_CustomThumbnail(object source, DevExpress.Web.FileManagerThumbnailCreateEventArgs e) {
switch(((FileManagerFile)e.Item).Extension) {
case ".avi":
e.ThumbnailImage.Url = "Images/movie.png";
break;
case ".zip":
e.ThumbnailImage.Url = "Images/archive.png";
break;
case ".txt":
e.ThumbnailImage.Url = "Images/txt.png";
break;
case ".rtf":
e.ThumbnailImage.Url = "Images/richtxt.png";
break;
case ".mp3":
e.ThumbnailImage.Url = "Images/music.png";
break;
case ".xml":
e.ThumbnailImage.Url = "Images/code.png";
break;
}
}