简体   繁体   中英

Images with Base64 Automatism - Javascript (with PHP?)

I heard a lot about Baase64 Encoding for Images in Webdesign.

And i saw a lot of developers they use it for thier headlines with: data:image/png;base64,iVBORw0...

Is there any automatism (with javascript) behind? Or have they all converted & inserted ? (could not belive)

Example: http://obox-inkdrop.tumblr.com/ (- Headlines)

First of all, the encoding has to be done on the server-side, be it :

  • automated with a script, that reads the original image file, and returns the base64 encoded string to inject it into the HTML that's being generated
  • or by hand, and directly placed into the HTML.

The base64 encoding cannot be done on the client-side, as the goal is to avoid sending the image file from the server to the browser (to minimize the number of HTTP requests) .


Depending of the language that's used on the server-side, you'll probably find some function to do base64 encoding.

In PHP, you might be interested by base64_encode()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM