Results 1 to 4 of 4

Thread: Embedding images in html

  1. #1
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184

    Embedding images in html

    When distributing your app, one suggestion from Barry has been to embed images in your webviews.

    Reading directions on the web is one thing; seeing an actual example is another, and often better (at least for me).

    Here's a site ( http://webcodertools.com/imagetobase64converter/Create ) where you can upload an image and get it done for you, so you can see what it would look like. Moving from there to what you want to do in your webview .rsp will depend on your needs, but at least you'll have a working example from which to start.

    What I would suggest is that you create a parser that looks for img tags, and then does the transformation for you. That way, you can develop with non-embedded images and when ready to distribute, can embed them. Oh, don't forget to contact the LianjaX administrators to get your code up on LianjaX. <s>

    enjoy,

    Hank

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184
    PS: you should also try out base64_encode_file(). it's not in the Wiki yet, but was mentioned in a post here: http://www.lianja.com/community/show...64_encode_file.

    You will find that it outputs text directly: because it's made to be used in an .rsp page, where that would be handy.

    If you want to output the text to a file (handy for embedding in an enhanced helpfile editor, for example), you will want to use SET ALTERNATE, which unless you were doing Fox programming in the early to mid-90's you might not remember (because you won't have had occasion to use it).

    SET ALTERNATE TO myfile.txt
    SET ALTERNATE ON
    =base64_encode_file("mypathedfile.png","png")
    SET ALTERNATE OFF
    SET ALTERNATE TO && doesn't write it out, although the file is already created, until you do this

    Now, you will have one little issue here: the command also returns a value, which appears to be the number of bytes in the file. This gets stuck at the end of your file.

    lcImage = getwordnum(filetostr("myfile.txt"),1,">") + ">"
    =strtofile(lcImage,"myfile.h")

    hth,

    Hank

  3. #3
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,162
    Blog Entries
    22
    In Lianja you don't need to say:

    =base64_encode_file("mypathedfile.png","png")

    Just omit the =

    base64_encode_file("mypathedfile.png","png")
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,184
    Yes, I'm aware of that; similarly in VFP. It's a reminder to me that there is a return value, in case I really should be doing something with it.

    thanks,

    Hank

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us