views:

56

answers:

3

I can embed a mime encoded JPEG in an html page by saving the page from IE using the File-SaveAs menu and selecting (Web Archive, single file (*.mht)).

Renaming this .mht file with .eml enables Outlook to open it and send an HTML email.

My questions are:

  1. How can I embed JPEG images directly in HTML pages (no external files). Are the images just mime encoded inline in the HTML?

  2. It appears that this is IE specific. Do any other browsers support this functionality?

+2  A: 

MHT files are not standard HTML. The only way to do this in standard HTML is using data URIs.

Matthew Flaschen
IE < 8 can't deal with data URIs.
Pekka
IE8 has limited support, which does include images < 32 KiB.
Matthew Flaschen
Ok, so I now have a google search term 'data URIs'. Do you have an example you can give?
'MHT files are not standard HTML.' Correct, this is why I say it appears to be IE specific.
@roygbiv: Check out http://en.wikipedia.org/wiki/Data_URI_scheme
Pär Wieslander
A: 

You could try a data: URL I suppose (it's got a public spec) but for anything more than a few hundred bytes that would be truly evil.

Donal Fellows
That, plus IE < 8 can't deal with it.
Pekka
@Pekka: So? Developing new things that support IE7 is a poor idea (easier to get the users to upgrade) and developing to support IE6 is a wicked and wrong-headed thing to do.
Donal Fellows
Also, data URIs are far more widely supported than MHT.
Matthew Flaschen
@Donal if you can afford to not support IE7, go ahead! I, for one, usually can't.
Pekka
+1  A: 

How can I embed JPEG images directly in HTML pages (no external files). Are the images just mime encoded inline in the HTML?

As other answerers point out, there is the concept of data URIs but it is not supported by IE before 8, which renders it pretty useless.

Also, data URIs base64-encode the binary data, increasing the data volume by 33%.

As far as I know, sadly, there is no cross-browser way to do this.

Pekka