HTML Text and Images

Ken Ray kray at sonsothunder.com
Wed Oct 6 11:56:03 EDT 2010


> On Tue, Oct 5, 2010 at 7:32 PM, Ray Horsley <ray at linkit.com> wrote:
> 
>>  If
>> worse comes to worse I can always just keep the image I create to get the
>> dimensions, resize it and use it instead.
>> 
> 
> I think this is the only way.
> 
> If you'd go with RevBrowser you could set image attribute such as height and
> width in the img tag but HTMLText does not work like that. Heck, I wish it
> was not called HTMLText but SGMLText or something like FancyTaggedText

Actually you can do it this way:

1) Retrieve the image from the web into an image object.
2) Change the size of the image object itself, making sure to keep the
dimensions consistent so you don't get stretching/skewing.
3) Lock the image object (set the lockLoc of <image> to true)
4) In your field, instead of setting the htmlText to the image with the ID
of the image object in <img src>.

Here's a simple example (I had to add a couple of returns before the text so
you could see the bird - watch linewraps):

on mouseUp
  set the lockLoc of img "testImage" to false
  set the filename of img "testImage" to ""
  set the filename of image "testImage" to
"http://linkit.com/Schools/ETS%20Items/ETS%20Item%20Bank/ETS10Q1/01%20Full%2
0Bank/04%20ELA%20QTI%20with%20GUIDs/Grade%20KLanguage%20Arts-95/images/38228
.jpg"
  set the width of img "testimage" to (the width of img "testimage"/4)
  set the height of img "testimage" to (the height of img "testimage"/4)
  set the lockLoc of img "testImage" to true
  set the htmlText of fld 1 to ("<P><P><P>Here's the bird <img src=" & quote
& (the id of img "testImage") & quote & ">")
end mouseUp

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list