Code is below. I think the line that is highlighted in code is the one that tells what src will be used for img tag. That code works perfectly as you can see from the html snippet (in red). First img tag is a result of using Insert Image button. Second is the result of using Image Galery button. Both work, both insert the correct image, image renders correctly (I have a base tag set so these are relative paths). For some reason however, Image Galery inserts put in height and width and I don't need nor want that.
Thanks.
----- html ---------
This is goran's template<br />
<br />
<img alt="" src="Public Web Site/Images/HandShake.jpg" border="0" />
<img height="30" alt="" src="Public Web Site/Images/HandShake.jpg" width="28" border="0" /><br />
<br />
-------- code --------
Option Strict On
Imports Microsoft.VisualBasic
Imports Cimmaron.XAP.FileManagement.BusinessObjects
Imports System.Configuration
Public Class XAPImageGalleryProvider
Inherits CuteEditor.Impl.FileStorage
Private ReadOnly mAppService As Cimmaron.XAP.Core.AppService.AppServiceBase = Cimmaron.XAP.Core.AppService.AppServiceBase.GetDefaultInstance
Private mContext As HttpContext
Private mRoot As String = "/"
Private Const CACHE_DURATION_IN_MINUTES As Integer = 5
Public Sub New(ByVal context As HttpContext)
MyBase.New(context)
mContext = context
End Sub
Public Overrides Function CopyDirectory(ByVal dirpath As String, ByVal targetdir As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function CopyFile(ByVal filepath As String, ByVal targetdir As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function CreateDirectory(ByVal dirpath As String, ByVal dirname As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function CreateFile(ByVal dirpath As String, ByVal filename As String, ByVal filedata() As Byte) As String
Throw New NotImplementedException
End Function
Public Overrides Sub DeleteDirectory(ByVal dirpath As String)
Throw New NotImplementedException
End Sub
Public Overrides Sub DeleteFile(ByVal filepath As String)
Throw New NotImplementedException
End Sub
Public Overrides Function GetDirectoryItems(ByVal dirpath As String, ByVal getcount As Boolean) As CuteEditor.Impl.DirectoryItem()
Dim f As Folder = GetFolderFromPath(dirpath)
Dim Folders As New ArrayList
For Each ChildFolder As Folder In f.ChildFolders
Dim DI As New CuteEditor.Impl.DirectoryItem
DI.Name = ChildFolder.Name
If getcount Then DI.ChildCount = ChildFolder.Documents.Count
DI.Path = "/F" & ChildFolder.FolderID
Folders.Add(DI)
Next
Return CType(Folders.ToArray(GetType(CuteEditor.Impl.DirectoryItem)), CuteEditor.Impl.DirectoryItem())
End Function
Public Overrides Function GetDirectorySize(ByVal dirpath As String) As Double
Dim f As Folder = GetFolderFromPath(dirpath)
Dim Size As Integer
For Each d As Document In f.Documents
If d.LinkFile = False Then Size = Size + d.FileSize
Next
Return Size
End Function
Public Overrides Function GetDirectoryText(ByVal dirpath As String) As String
dirpath = CalcPath(VirtualRoot, dirpath)
Dim f As Folder = GetFolderFromPath(dirpath)
Return f.Name
End Function
Public Overrides Function GetFileData(ByVal filepath As String) As Byte()
filepath = CalcPath(VirtualRoot, filepath)
If filepath.IndexOf("F") >= 0 Then Return Nothing
Dim d As Document = GetCachedDocument(CInt(filepath.Replace("/D", "")))
Return d.Buffer
End Function
Public Overrides Function GetFileItems(ByVal dirpath As String, ByVal searchpattern As String) As CuteEditor.Impl.FileItem()
dirpath = CalcPath(VirtualRoot, dirpath)
Dim FileList As New ArrayList
Dim f As Folder = GetFolderFromPath(dirpath)
For Each Doc As Document In f.Documents
If Doc.Extension = searchpattern.Substring(searchpattern.LastIndexOf(".") + 1) OrElse searchpattern = "*.*" Then
Dim FI As New CuteEditor.Impl.FileItem
FI.CreationTime = Doc.DateEntered
If Doc.DateUpdated.HasValue Then FI.LastWriteTime = Doc.DateUpdated.Value
FI.Length = Doc.FileSize
FI.Name = Doc.FriendlyFileName
FI.Path = "/D" & Doc.DocumentID
FI.Url = Doc.LogicalPath.TrimStart("/"c)
FileList.Add(FI)
End If
Next
Return CType(FileList.ToArray(GetType(CuteEditor.Impl.FileItem)), CuteEditor.Impl.FileItem())
End Function
Public Overrides Function GetFileName(ByVal filepath As String) As String
filepath = CalcPath(VirtualRoot, filepath)
If filepath = "/" Then Return Nothing
If filepath.IndexOf("F") >= 0 Then Return Nothing
Dim d As Document = GetCachedDocument(CInt(filepath.Replace("/D", "")))
Return d.FriendlyFileName
End Function
Public Overrides Function GetFileUrl(ByVal filepath As String) As String
Return Nothing
End Function
Public Overrides Function GetParentDirectory(ByVal dirpath As String) As String
dirpath = CalcPath(VirtualRoot, dirpath)
If dirpath = "/" Then Return Nothing
If dirpath.IndexOf("D") >= 0 Then Return Nothing
Dim f As Folder = GetCachedFolder(CInt(dirpath.Replace("/F", "")))
Return f.ParentFolderID.ToString
End Function
Public Overrides Function MoveDirectory(ByVal dirpath As String, ByVal targetdir As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function MoveFile(ByVal filepath As String, ByVal targetdir As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function RenameDirectory(ByVal dirpath As String, ByVal name As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function RenameFile(ByVal filepath As String, ByVal name As String) As String
Throw New NotImplementedException
End Function
Public Overrides Function TranslateTargetDirectory(ByVal dirpath As String, ByVal relpath As String) As String
Throw New NotImplementedException
End Function
Public Overrides Property VirtualRoot() As String
Get
Return mRoot
End Get
Set(ByVal value As String)
mRoot = value
End Set
End Property
Private Function CalcPath(ByVal Path As String, ByVal RelPath As String) As String
Path = Path.Replace("\\", "/")
If Not Path.StartsWith("/") Then Path = CalcPath(VirtualRoot, Path)
If RelPath Is Nothing OrElse RelPath = "" Then Return Path
If RelPath.StartsWith("/") Then
If RelPath.IndexOf("..") <> -1 Then Throw (New Exception("Absolute path can't contain '..'"))
If (RelPath = "/") Then Return RelPath
Return RelPath.TrimEnd("/"c)
End If
If Path = "" Then Return "/"
Return Path.Replace("//", "/")
End Function
Private Function GetCachedDocument(ByVal DocumentID As Integer) As Document
Return New Document(DocumentID)
End Function
Private Function GetCachedFolder(ByVal FolderID As Integer) As Folder
Return New Folder(FolderID)
End Function
Private Function GetFolderFromPath(ByVal DirPath As String) As Folder
DirPath = CalcPath(VirtualRoot, DirPath)
Dim FolderID As Integer
If DirPath = VirtualRoot Then
FolderID = CInt(ConfigurationManager.AppSettings("RootPublicWebSiteFolder"))
Else
FolderID = CInt(DirPath.Replace("/F", ""))
End If
Dim f As Folder = GetCachedFolder(FolderID)
Return f
End Function
End Class