Handling Wrong Image Tags

4 posts, 0 answers
  1. Boas
    Boas avatar
    9 posts
    Member since:
    Sep 2008

    Posted 30 Aug 2011 Link to this post

    Hi

    I'm currently evaluating the RichtextControl of Telerik.

    When I try to import HTML with a image tag, which has an image that does not exist, I got a pixelFormat error.

    How can I handle missing images in HTML  ?

    Here is the load code

      public void Load(string htmlInput)
            {
     
                HtmlFormatProvider provider = new HtmlFormatProvider();
            
                RadDocument telDoc = provider.Import(input);
                telerikTextBox.Document = telDoc;
     
                //spellchecker language anpassen
                telerikTextBox.IsSpellCheckingEnabled = false;
     
                this.telerikTextBox.SpellChecker.SpellCheckingCulture = new CultureInfo("en-US");        
                     }

    I tried it with the  using the
    LoadImageFromUrl
    
    event from HtmlImportSettings


    But this didn't helped

     Bitmap image = new Bitmap(16, 16);
     
            void settings_LoadImageFromUrl(object sender, LoadImageEventArgs e)
            {
                if (e != null)
                {
     
                    MemoryStream memStream = new MemoryStream();
     
                    image.Save(memStream, ImageFormat.Bmp);
     
                   
     
                     e.ImageElement.Init(memStream, ".bmp");
                }
            }
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 31 Aug 2011 Link to this post

    Hello Boas,

    There was a bug with the event LoadImageFromUrl not being fired whenever needed. This issue was fixed and will be visible in the next internal build.
    We have also fixed the import of images with lacking or invalid sources, so the exception won't be thrown in the first place.
    We are sorry for the inconvenience.

    Greetings,
    Iva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Alexander
    Alexander avatar
    2 posts
    Member since:
    Aug 2011

    Posted 01 Sep 2011 Link to this post

    Im having the exact same issue, but also the development build (0823) did not help as well, do i miss something?

    I'm using the
            <telerikHtml:HtmlDataProvider Name="htmlDataProvider" Html="{Binding SourceCode,Mode=TwoWay}" RichTextBox="{Binding ElementName=richTextBox}" />
    and set the SourceCode to some HTML with an invalid picture path aka <img src="haha" /> --> crash, NotSupportedException

    When you fix this issue, is it possible to export these invalid pictures with the same path again as you tried to import?
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 02 Sep 2011 Link to this post

    Hello Alexander,

    The fix for images with unrecognized sources will be included in the next LIB, which will probably be released on Tuesday; the issue is not fixed in build 0823.
    When it comes to the export of the images with the same src that they have been set before the import, this has also been implemented and will be visible once the LIB is out.

    Kind regards,
    Iva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top