How do you insert an HTML image

  • I have wptools 6 and it is loading html pages and images very nicely (after adding graphex and synapse libraries). My question is how can I insert picture where the source is a web image (e.g.,http://www.abccompany.com/images/logo.jpg)? I've searched the groups and the manuals and can't find what I am looking for. Basically, I want the user to be able to enter an image URI (e.g., http://www.abccompany.com/images/logo.jpg) and have that insert the appropriate image code and display the image inside the wprichtext control. Something that results in rtf code along the lines of:

    {\*\wppicsource{http://www.abccompany.com/images/logo.jpg}}
    {\field{\*\fldinst{INCLUDEPICTURE "http://www.abccompany.com/images/logo.jpg" MERGEFORMAT \\d \\w11250 \\h1575}


    Help is appreciated (I have tried the inputhyperlink code below and similar inputstring code but it does not work):

    var
    imageurl : string;
    begin
    imageurl := '<a href="#"><img src="http://www.euclidtechnology.com/images/innerLogo.gif" </a>';
    imageurl := InputBox('Enter Image URL','URL',imageurl);
    mmoudcpro.InputHyperlink(imageurl, 'link');

    • Offizieller Beitrag

    I did not expect this demand, so it is a bit more complicated:

    Next release will this make it as easy as
    WPRichText1.TextObjects.InsertFromHTTP(url, true);

    Regards,

    Julian

  • Thanks Julian. I was just about to post the following code that I just now got to work. Can you tell me if one solution is better than the other? Note that mmoudcpro is the name of the richtext control

    • Offizieller Beitrag

    Hello,

    my approach is more universal, but TWPOImage is completely ok since it handles all image formats.

    The last parameter in LoadHTTPFromThread is "threaded". If it is true, the image will be loaded in a seperate thread. You need to use 'wpobjImageNotLoaded' in modes if you do this. In Your case, you dont, so it is fine.

    InputObject is the same as TextObjects.Insert, so it is fine.

    It returns the TWPTextObj instance, if this value is nil, please free the TWPObject instance, otherwise dont free it.

    Kind Regards,
    Julöian