Created
September 29, 2010 13:44
-
-
Save roelven/602761 to your computer and use it in GitHub Desktop.
DataURIze all images in a dir with PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
- Check folder images for available images files (I used gif only in this case) | |
- Loop through all images and render them inline in HTML, using dataURI's with Base64 encoding through PHP | |
- View the output in your browser to get the encoded strings | |
*/ | |
$path = 'images/'; | |
$handle = opendir($path); | |
while (($file = readdir($handle)) != false) { | |
if(strlen($file) > 3) { | |
print '<img src="data:image/gif;base64,'.base64_encode(file_get_contents($path.$file)).'"> <br />'."\n"; | |
} | |
} | |
closedir($handle); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment