-2

I have a question about this piece of code:

redirectUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="

When I include this piece of code, all pictures on a website dont get loaded. But what does this encoder do?

Does it block pictures, hides them or just isn't loading them?

kamito dono
  • 47
  • 1
  • 7
  • THIS bit of code does nothing. The sizeable chunk around it does. – Xan May 03 '16 at 11:52
  • `atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==')` is the binary data of your image. – Oriol May 03 '16 at 11:54

2 Answers2

2

data describes the protocol. (like.. ftp, http, https etc.)
: separates the protocol from its parameters
since its data, the following chunk: image/png describes the type of the data.
At this position could come other information like content language etc.
;base64 describes the encoding of the data
, separates the header from the data
iVBORw0KG… the actual data to be presented.

You can read more on it here: https://en.wikipedia.org/wiki/Data_URI_scheme

Your provided png is a 1x1 pixel image that contains a transparent pixel.

GottZ
  • 4,824
  • 1
  • 36
  • 46
  • but then why isnt it showing any pictures when i only include that code? what does it do with the pictures. – kamito dono May 03 '16 at 12:21
  • @kamitodono By itself, it doesn't. It's the code that's around this snippet that does something. Without context, I can guess what happens (from `redirectUrl` name), but it's impossible to answer in detail. – Xan May 03 '16 at 12:32
0

data:image/png;base64 simply instructs the parser that it's a base 64 encoded png image. Make it a header if you will.

overburn
  • 1,194
  • 9
  • 27