This is a migrated thread and some comments may be shown as answers.

Handling Wrong Image Tags

3 Answers 86 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Boas
Top achievements
Rank 1
Boas asked on 30 Aug 2011, 10:47 AM
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");
            }
        }

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 31 Aug 2011, 04:52 PM
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 >>

0
Alexander
Top achievements
Rank 1
answered on 01 Sep 2011, 04:23 PM
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?
0
Iva Toteva
Telerik team
answered on 02 Sep 2011, 09:36 AM
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 >>

Tags
RichTextBox
Asked by
Boas
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or