SEARCH
Tag Archives: smarty
Smarty template function for the data uri format
Posted in: Blog, PHP by Craig Davis on February 12, 2009
In a recent project, I needed to provide an html document that could be used offline. After initially experimenting with zip files and other methods of delivering the associated image files, I chose to use the somewhat rare method of using the data uri scheme. This provides us with the ability to place the image data in-line with the page.
The approach is straightforward. We must base64 encode the image data and place it with the proper formatting into the src attribute of an img tag. The processing is accomplished in this case with a smarty modifier.
<img src="{img2data path='/images/inline.gif'}" />