Modifying Resource Browser to Display Thumbnail for Bitmaps
The Resource Browser (Web Author - Resource Manager) ships with MCMS doesn't provide a thumbnail preview for bmp files. That is acceptable as bmp is not a web image format. But if you are interested in showing a thumbnail for bmp files, it can be done via a customized Resource Manager.
1. Create a class inheriting Microsoft.ContentManagement.WebAuthor.ResourcesBrowse
a) Create a class library.
b) Body of the class -
using System;
using System.Drawing;
using Microsoft.ContentManagement.WebAuthor;
using Microsoft.ContentManagement.Publishing;
namespace MCMS
{
public class CustomResourceBrowser : ResourcesBrowse
{
public CustomResourceBrowser()
{
}
//Create a new method to hide the default DataBindResourceColumnThumbnailUrl
protected new string DataBindResourceColumnThumbnailUrl(object dataitem)
{
Resource resource = (Resource)dataitem;
string url = string.Empty;
IntPtr Missing = IntPtr.Zero;
if(resource.FileExtension.ToLower()=="bmp")
{
using(Image image = Bitmap.FromStream(resource.OpenReadStream()))
{
using(Image thumbImage = image.GetThumbnailImage(32,32,null,Missing))
{
thumbImage.Save(@"PhysicalPath"+resource.Name,System.Drawing.Imaging.ImageFormat.Icon);
url = "http://WebPath/"+resource.Name;
}
}
}
else
{
url = resource.UrlThumbnail;
}
return url;
}
}
}
2. Add the following references
a) using System.Drawing
b) System.Web
c) using Microsoft.ContentManagement.WebAuthor
d) using Microsoft.ContentManagement.Publishing
3. Create a temporary folder with appropriate rights for a web user to write data to that. Have the folder in a saver place as it can be assessed by anyone. Make it as a virtual directory. In the PhysicalPath above class replace it with the path of this directory and WebPath with the virtual directory name.
4. Deploy the dll in the bin folder of your MCMS project.
5. Make a copy of ResourcesBrowse.aspx - its default location "C:\Program Files\Microsoft Content Management
Server\Server\IIS_CMS\WebAuthor\Dialogs\ResourceBrowser\Management\"
6. Open ResourcesBrowse.aspx in notepad and change the Page derivative as bellow
<%@ Page language="c#" Codebehind="ResourcesBrowse.aspx.cs" SmartNavigation="true" AutoEventWireup="false"
Inherits="MCMS.CustomResourceBrowser" %>
This will make thumbnail in the temporary folder for bitmap files, which will be referred by Resource Manager - used to show the preview.
Note: Take precautions before using this method as ResourcesBrowse.aspx may get changed without any notification.
1. Create a class inheriting Microsoft.ContentManagement.WebAuthor.ResourcesBrowse
a) Create a class library.
b) Body of the class -
using System;
using System.Drawing;
using Microsoft.ContentManagement.WebAuthor;
using Microsoft.ContentManagement.Publishing;
namespace MCMS
{
public class CustomResourceBrowser : ResourcesBrowse
{
public CustomResourceBrowser()
{
}
//Create a new method to hide the default DataBindResourceColumnThumbnailUrl
protected new string DataBindResourceColumnThumbnailUrl(object dataitem)
{
Resource resource = (Resource)dataitem;
string url = string.Empty;
IntPtr Missing = IntPtr.Zero;
if(resource.FileExtension.ToLower()=="bmp")
{
using(Image image = Bitmap.FromStream(resource.OpenReadStream()))
{
using(Image thumbImage = image.GetThumbnailImage(32,32,null,Missing))
{
thumbImage.Save(@"PhysicalPath"+resource.Name,System.Drawing.Imaging.ImageFormat.Icon);
url = "http://WebPath/"+resource.Name;
}
}
}
else
{
url = resource.UrlThumbnail;
}
return url;
}
}
}
2. Add the following references
a) using System.Drawing
b) System.Web
c) using Microsoft.ContentManagement.WebAuthor
d) using Microsoft.ContentManagement.Publishing
3. Create a temporary folder with appropriate rights for a web user to write data to that. Have the folder in a saver place as it can be assessed by anyone. Make it as a virtual directory. In the PhysicalPath above class replace it with the path of this directory and WebPath with the virtual directory name.
4. Deploy the dll in the bin folder of your MCMS project.
5. Make a copy of ResourcesBrowse.aspx - its default location "C:\Program Files\Microsoft Content Management
Server\Server\IIS_CMS\WebAuthor\Dialogs\ResourceBrowser\Management\"
6. Open ResourcesBrowse.aspx in notepad and change the Page derivative as bellow
<%@ Page language="c#" Codebehind="ResourcesBrowse.aspx.cs" SmartNavigation="true" AutoEventWireup="false"
Inherits="MCMS.CustomResourceBrowser" %>
This will make thumbnail in the temporary folder for bitmap files, which will be referred by Resource Manager - used to show the preview.
Note: Take precautions before using this method as ResourcesBrowse.aspx may get changed without any notification.


1 Comments:
Private Label Rights
Post a Comment
<< Home