Join David Powers for an in-depth discussion in this video Batch convert images to data URIs, part of PHP Tips, Tricks, and Techniques.
- [David] Hi, I'm David Powers…and welcome to this week's edition of PHP Tips and Tricks…designed to help you become a smarter,…more productive PHP developer…Choose Cheese.…Well, tempting though that prospective is…the focus this week is on these icons of national flags…of various countries.…At the moment they're separate images…and each one requires a separate request to the server.…To reduce the load on the server…they could be combined into a CSS sprite…but that involves troublesome calculations…to get the correct background position.…
The alternative is to use what's known as a data URI.…This involves encoding the graphic data…for each image as a string…ready to embed it in either a style sheet or into HTML.…Using PHP to batch process images…to data URIs is quick and easy,…so that's what we'll do this week.…The format of a data URI is simple.…It begins with data followed by a colon.…That's followed by the MIME type…and a semicolon.…
So, if it's a JPEG,…the MIME type is image/jpeg.…Next comes the encoding…which is base64 and a comma…
Note: The exercise files are free to all members. The code is commented to enhance your learning, but you will need database connectivity for some files to run as intended.
Skill Level Intermediate
PHP: Managing Persistent Sessionswith David Powers2h 41m Intermediate
New this Week:
Strip accents from text New9m 29s
1. Weekly Episodes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.