homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Embedding Image Code Directly into HTML
The data itself, not a link to the data file
otem




msg:3311692
 3:51 pm on Apr 15, 2007 (gmt 0)

Is it possible in HTML to embed an image source directly into the code?

I'm not interested in linking to an image, but actually putting that information directly into my HTML document.

My site uses dynamic png images which I create using PHP to verify that a human is inputing data into a form. Right now I have traditionaly link to these images (php pages) and the requested file gives a png header and the image source code.

Since I'm using PHP to generate my html, I'm wondering if I'm just able to embed this code directly into my html reducing loading time and server requests.

An added advantage this might have would be I might not have to worry about the browser chaching the image.

Thanks.

 

Little_G




msg:3311697
 4:02 pm on Apr 15, 2007 (gmt 0)

Hi,

There is the data uri scheme [en.wikipedia.org] but it's not supported by IE.

Andrew

whoisgregg




msg:3311709
 4:13 pm on Apr 15, 2007 (gmt 0)

I'm afraid I don't have an actual answer to your main query. I can address one bit of your post though. :)

An added advantage this might have would be I might not have to worry about the browser chaching the image.

You can add headers to your captcha-generating PHP file to prevent caching (in most cases).

This thread [webmasterworld.com] has an example of how to achieve this plus a search at your favorite search engine for "php header prevent caching" should turn up plenty of results.

otem




msg:3311729
 4:48 pm on Apr 15, 2007 (gmt 0)

Its a shame its not fully supported, that would have been exactly what I was looking for. Thanks for the information though.

Also, thanks for the tip about the headers. I currently do use headers to prevent caching, but this would have made them obsolete.

Thanks

Little_G




msg:3311740
 5:01 pm on Apr 15, 2007 (gmt 0)

Hi,

One other possibility (maybe a long shot) is HTML Table images [neil.fraser.name] with a lower resolution to help with loading time.

Andrew

[edited by: Little_G at 5:02 pm (utc) on April 15, 2007]

rocknbil




msg:3311849
 7:14 pm on Apr 15, 2007 (gmt 0)

My site uses dynamic png images which I create using PHP to verify that a human is inputing data into a form. Right now I have traditionaly link to these images (php pages) and the requested file gives a png header and the image source code.

I think I get where you're going - for security possibly?

What you can do is create a second script, call it an "image generator." Then do

<img src="img_gen.php?id=some_id">

img_gen.php would have to slurp up the file and output a content-type:image/png header (wild guess, you get the idea) and dynamically output the image.

If it's just caching you're worried about, generate a unique id for each image file name before output:

<img src="some_image.png?23456788">

souFrag




msg:3311871
 7:51 pm on Apr 15, 2007 (gmt 0)

If it's just caching you're worried about, generate a unique id for each image file name before output:

<img src="some_image.png?23456788">


You may also add this to some_image.php so that a different filename is sent everytime to the browser:

header('Content-Disposition: filename=' . mt_rand(0, 9999) . '.png');

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved