Insert Image as absolute URL

6 posts, 0 answers
  1. Emerson
    Emerson avatar
    8 posts
    Member since:
    Nov 2011

    Posted 15 Nov 2011 Link to this post

    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
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 21 Nov 2011 Link to this post

    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 >>

  3. Emerson
    Emerson avatar
    8 posts
    Member since:
    Nov 2011

    Posted 22 Nov 2011 Link to this post

    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?
  4. Boby
    Admin
    Boby avatar
    624 posts

    Posted 25 Nov 2011 Link to this post

    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 >>

  5. Mohamed
    Mohamed avatar
    6 posts
    Member since:
    May 2008

    Posted 21 Dec 2011 Link to this post

    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.


  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 22 Dec 2011 Link to this post

    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 >>

Back to Top