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

Insert Image as absolute URL

5 Answers 888 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Emerson
Top achievements
Rank 1
Emerson asked on 15 Nov 2011, 06:08 PM
Hi there

Could anyone please tell me how can I enable my RichTextBoxRibbonUI to insert an image using an absolute URL as the source.

Instead of the OpenFileDialog, I want to type http://www.host.com/images/image.jpg

I saw this post here:
http://www.telerik.com/community/forums/silverlight/richtextbox/inserting-an-image-in-the-radrichtextbox.aspx

But sitll have no idea how to implement it, on both xaml and .cs sides.

Thanks

Emerson de Mello

5 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 21 Nov 2011, 05:42 PM
Hi Emerson,

You can insert an image from a URL in the following way:

this.editor.InsertInline(new ImageInline(url));
where url is the Uri of the image you want to insert, e.g.:

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Emerson
Top achievements
Rank 1
answered on 22 Nov 2011, 10:55 AM
Thanks for your reply.

What command behaviour should I insert this code?
How can I ensure when I press the Insert Image from the RichTextBoxRibbonUI, the command does not show the OpenFileDialog box and then access the code behind opening another dialog asking the user to type in the image URL?
0
Boby
Telerik team
answered on 25 Nov 2011, 09:43 AM
Hi Emerson,
You could remove the button's default binding code:
telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=InsertPictureCommand}"
and bind the button's Command property to your custom command (or use an event handler) showing your custom dialog and performing the above mentioned logic.

Don't hesitate to contact us if you have other questions.

Kind regards,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mohamed
Top achievements
Rank 1
answered on 21 Dec 2011, 04:58 PM
Hi Boby,
 I followed the above and image does not display correctly. 
private void RadRibbonButton_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    this.editor.InsertInline(new ImageInline(url));
}

My RichTextBox control is an email editor. I am trying to send the html output as an email from the wpf application. I am using HtmlDataProvider. If I use inline image, the image is not displaying in the email client as well even after trying with various browsers.

 The snapshot is attached.


0
Iva Toteva
Telerik team
answered on 22 Dec 2011, 08:19 PM
Hi Mohamed,

Most of the email clients blocks inline images which are included in the HTML document with their raw data.

You could customize the export of images of HtmlFormatProvider by setting the ImageExportMode and eventually handling ImageExportingEvent of HtmlExportSettings class (as described in this article).

All the best,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Emerson
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Emerson
Top achievements
Rank 1
Boby
Telerik team
Mohamed
Top achievements
Rank 1
Share this question
or