3

I am using Symfony and I found this in the source of an image of one template:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAABUElEQVQoz2NgAIJ29iBdD0d7X2cPb+tY2f9MDMjgP2O2hKu7vS8CBlisZUNSMJ3fxRMkXO61wm2ue6I3iB1q8Z8ZriDZFCS03fm/wX+1/xp/TBo8QPxeqf+MUAW+QIFKj/+q/wX/c/3n/i/6Qd/bx943z/Q/K1SBI1D9fKv/AhCn/Wf5L5EHdFGKw39OqAIXoPpOMziX4T9/DFBBnuN/HqhAEtCKCNf/XDA/rZRyAmrpsvrPDVUw3wrkqCiLaewg6TohX1d7X0ffs5r/OaAKfinmgt3t4ulr4+Xg4ANip3j+l/zPArNT4LNOD0pAgWCSOUIBy3+h/+pXbBa5tni0eMx23+/mB1YSYnENroT5Pw/QSOX/mkCo+l/jgo0v2KJA643s8PgAmsMBDCbu/5xALHPB2husxN9uCzsDOgAq5kAoaZVnYMCh5Ky1r88Eh/+iABM8jUk7ClYIAAAAAElFTkSuQmCC" alt="Search on Symfony website" />

What it means and how to create my own code?

Thanks.

kilkadg
  • 2,157
  • 4
  • 16
  • 21

4 Answers4

5

This is a URI scheme (Uniform Resource Identifier scheme) that provides a way to include data in-line in web pages as if they were external resources.

See here http://en.wikipedia.org/wiki/Data_URI_scheme for a longer description.

You can encode your own here:

http://webcodertools.com/imagetobase64converter

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
2

That's a base64-encoded image embedded directly in the page. If you want to generate your own, the base64 utility on any Linux system will do this:

base64 image.png

and just copy that string into your image tag.

<img src="data:image/png;base64,LONGSTRINGOFASCIICHARACTERS" alt="..." />
Christian Ternus
  • 8,406
  • 24
  • 39
1

It's the data URI scheme, it is a way to provide the actual content of the resource in the URI (instead of the location where to find it).

There are example code on how to generate them in the linked wikipedia page, but as you can see in the sample you gave it's pretty easy to generate one; give the mime type, the encoding used and then the content.

Lepidosteus
  • 11,779
  • 4
  • 39
  • 51
0

This is a url in 'data uri scheme'.

Pateta
  • 430
  • 4
  • 15