aspnet-8878-components-file-management-file-manager-concepts-thumbnails.md
ASPxFileManager automatically creates thumbnails for image files with the following file extensions:
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.
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.
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;
}
}
<dx:ASPxFileManager ID="ASPxFileManager1" runat="server" OnCustomThumbnail="ASPxFileManager1_CustomThumbnail">
<Settings RootFolder="~/Content/FileManager/Files" ThumbnailFolder="~/Content/FileManager/Thumbnails"
AllowedFileExtensions=".jpg,.rtf,.txt,.avi,.png,.mp3,.xml" InitialFolder="Documents" />
<SettingsUpload Enabled="false"></SettingsUpload>
</dx:ASPxFileManager>
See Also