Genii Weblog

Data URIs for small embedded images

Wed 4 Sep 2013, 05:45 PM



by Ben Langhinrichs
One of the small features that has been added in Midas V5 is support for generating data URIs. These allow the content of a data object, particularly an image, to be converted to Base64 and stored directly in the HTML. For example, this image Embedded gif image is embedded in the HTML. The source for it looks like:

<img 
src="data:image/gif;base64,R0lGODlhFQAVANUAAAAAAP///1aOwbTM38fHxfDw7+vr6
qiop/7xi+fm49nX09bU0OXk4sjHxfOrOfStPPWwQfazR/i2Tvq6VPu9WvzAX9DNyOjm497c2
dDNycGtpYRaS7mBbfz8/N7e3svLy8rKysHBwa2trYiIiGZmZv///wAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAACH5BAEAACUALAAAAAAVABUAAAaPwJJwSCwaj8ikcslsOoeiqHQ6PYo62KwWS
wIZr4WwODwQdLrfznhcPnuLnw7nMDKM7geDwW30cDYEDQwEhAQMDHxFHAgbFwmOFwoYk4lDi
xQbHJqaGhkLC5UlixUUCKanGyEZFqGjFBMSERAPDht7XG9DGwiYG76+cyTCaEW7GyDIycrIR765TyXH0NPURUEAOw==" alt="Embedded gif image" height="21" width="21" 
border="0">

which is pretty hideous, but this allows the images to be part of the single HTML file instead of requiring separate image files or integrated MIME files. As you might guess, this allows capsule views in HTML rather than just in MIME, though that is not the main goal, just a side benefit.

Copyright © 2013 Genii Software Ltd.

What has been said:

No documents found