Image tag problems when pasting from Image Galery.

Last post 12-22-2011, 12:54 PM by gorans@cimmaronsoftware.com. 5 replies.
Sort Posts: Previous Next
  •  08-13-2008, 5:20 PM 42946

    Image tag problems when pasting from Image Galery.

    I just download latest Cute Editor today so I have the latest version. File is dated 8/7/2008. I have implemented my own custom image gallery provider that has worked great up until today. Today, when I paste an image from my image galery selector, width and height attributes are added to the img tag. This happens 9 out of 10 times. Width is always 28 and height is always 30, and these are nowhere in my code. I am not sure if this is some new setting that I am missing but I would really appreciate your help.
     
    Goran.
  •  08-13-2008, 11:23 PM 42949 in reply to 42946

    Re: Image tag problems when pasting from Image Galery.

    Goran,
     
    Can you post your code of custom image gallery provider?

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-14-2008, 12:05 AM 42953 in reply to 42949

    Re: Image tag problems when pasting from Image Galery.

    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

  •  08-14-2008, 1:42 PM 42975 in reply to 42953

    Re: Image tag problems when pasting from Image Galery.

    Please open CuteSoft_Client\CuteEditor\Scripts\Dialog\Dialog_InsertGallery.js
     
    And add the following code to the bottom of the page:
     
    function insert(src) {
     if (src)
     {
      var url = src.replace(new RegExp("^[a-z]*:[/][/][^/]*",""), "");
           
      function Actualsize()
      {    
       var original = new Image();
       original.src = url;
       if(original.width>0&&original.height>0)
       {       
       } 
       else
       { 
        setTimeout(Actualsize, 400);    
       }  
      } 
      
      if(element)
      {
       element.src=url;
      }
      else
      {
       element=editdoc.createElement("IMG");
       element.src=url;
       element.border=0;
       element.alt="";
       Actualsize();
      }
       
      if(navigator.product == "Gecko")
      {
       try
       {
        element.setAttribute("src_cetemp",url);    
       }
       catch(e)
       {
       }
      }
      else
      {
       if(editor.GetActiveTab()=="Edit")
        element.setAttribute("src_cetemp",url);
      }
      editor.InsertElement(element);
      Window_CloseDialog(window);
     }
    }

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-14-2008, 5:32 PM 42982 in reply to 42975

    Re: Image tag problems when pasting from Image Galery.

    Adam,
     
    Thank you, that worked. Now is this something that was a bug in your js file and next time I get the update it will be fixed, or do I need to remember to update the file every time I download a new release?
     
    Thanks.
    Goran.
     
  •  12-22-2011, 12:54 PM 72411 in reply to 42982

    Re: Image tag problems when pasting from Image Galery.

    This problem is back with 6.6 version. What can I do to remove width and height from my img tag?

    Goran
View as RSS news feed in XML