Approved
Last Updated: 31 Oct 2018 07:53 by ADMIN
ADMIN
Petya
Created on: 23 Jun 2015 14:29
Category: RichTextBox
Type: Bug Report
2
RichTextBox: Image (<img>) that doesn't have 'width' and 'height' attributes set to it inherits them from the table it is in when importing from HTML
The width of the image is inherited from the table element it is in when it doesn't have a specific width set to it. Sample HTML reproducing the problem is:

<html>
	<body>
		<table style="width: 700px;">
			<tbody>
				<tr>
					<td>
						<img src="" />
					</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>

Instead, the real size of the image should be used.

Workaround: Subscribe to LoadImageFromUri and set size to the image.

            settings.LoadImageFromUrl += (s, arg) =>
                {
                    if (arg.Url != null)
                    {
                        string extension = Path.GetExtension(arg.Url);
                        Uri uri = new Uri(arg.Url, UriKind.RelativeOrAbsolute);
                        System.Net.WebClient oWebClient = new System.Net.WebClient();

                        using (MemoryStream stream = new MemoryStream())
                        {
                            oWebClient.OpenRead(uri).CopyTo(stream);
                            arg.ImageElement.Init(stream, extension);
                            arg.ImageElement.Size = new Size(164, 80);

                            e.Handled = true;
                        }
                    }
                };
0 comments