http://en.wikipedia.org/wiki/Data_URI_scheme
PHP has a function to do this.
Either an explicit prefix="data:image/png;base64," or an automatc AsUrl=true
If it was a new function, I'd probably be in favour of toBase64Uri
Unless there are different (non-Base64) ways of doing this, in which
case I'd say toDataUri ( data , 'base64' ) or similar.
i favour: toDataUri ( data, 'base64' )
where data could be: URL, pathname, or a binary data type.
--
CFML Conventional Wisdom
http://groups.google.com/group/cfml-conventional-wisdom?hl=en?hl=en
--
aw2.0 ltd www.aw20.co.uk
Looking at the wikipedia entry, that's a fair amount of code, for instance to produce a small red dot, <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" /> I cannot see the advantage over <img src="image/smallRedDot.png" alt="Red Dot" /> Maybe I am missing something.
Inline images use the
data:
URL scheme to embed the image data in the actual page. This can increase the size of your HTML document. Combining inline images into your (cached) stylesheets is a way to reduce HTTP requests and avoid increasing the size of your pages. Inline images are not yet supported across all major browsers.Reducing the number of HTTP requests in your page is the place to start. This is the most important guideline for improving performance for first time visitors. As described in Tenni Theurer's blog post Browser Cache Usage - Exposed!, 40-60% of daily visitors to your site come in with an empty cache. Making your page fast for these first time visitors is key to a better user experience.
I like it, but can it be anything besides base64? Maybe it should be
mime type or something as the second argument, overriding whatever the
automatic type check returns?
:Den
--
The world is all a carcass and vanity, The shadow of a shadow, a play
And in one word, just nothing.
Michel de Montaigne
I propose this:
toDataUri(data, mimeType:auto, encoding:base64)
The mime-type is auto discovered -- I don't expect any magic numbers
type of checking. A straight "general" file extension to mime-type map
is fine with me. By default, everything is base64 encoded.
Most of the time I bet this is what you'd see:
toDateUri(data)
.pjf
Exactamundo!
> I propose this:
>
> toDataUri(data, mimeType:auto, encoding:base64)
>
> The mime-type is auto discovered -- I don't expect any magic numbers
> type of checking. A straight "general" file extension to mime-type map
> is fine with me. By default, everything is base64 encoded.
Yuppers. If you had to add the second param, it would be when passing
pure data, vs a file path.
:Den
--
The worst of my actions or conditions seem not so ugly unto me as I
find it both ugly and base not to dare to avouch for them.
Michel de Montaigne
Assuming you can pass pure data. :)
Perhaps an encoding attribute would be needed, or would that be picked
up from the context?
:Den
--
There are some defeats more triumphant than victories.
Michel de Montaigne