View Issue Details

IDProjectCategoryView StatusLast Update
835Composrcorepublic2012-09-23 22:04
ReporterChris Graham Assigned ToChris Graham  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
Summary835: Automatic data URI generation
DescriptionWe could quite easily make a symbol that creates data URIs for theme images, instead of URLs. E.g. $IMG_DATA.

This saves on request volume, embedding images directly into the CSS.
Additional InformationSample code found online...

// A few settings
$image = 'cricci.jpg';

// Read image path, convert to base64 encoding
$imageData = base64_encode(file_get_contents($image));

// Format the image SRC: data:{mime};base64,{data};
$src = 'data: '.mime_content_type($image).';base64,'.$imageData;

// Echo out a sample image
echo '<img src="',$src,'">';
TagsType: Performance
Attach Tags
Time estimation (hours)2
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Activities

Chris Graham

2012-09-21 14:37

administrator   ~985

NB: There's a 32kb length limit in IE8, so make sure that if that is exceeded a normal URL is put in instead.

Issue History

Date Modified Username Field Change