*/ /** * patTemplate modifier Base64 * * Base64 encode file * * @package patTemplate * @package Modifiers * @author gERD Schaufelberger */ class patTemplate_Modifier_Base64 extends patTemplate_Modifier { /** * Modify the Value * * @param string value * @param array $params * @return string modified value */ public function modify($value, $params = array()) { $params = array_merge(array( 'mime' => 'image/png' ), $params); $path = sprintf('%s/%s' , WBParam::get('wb/dir/base') , $value); $fmt = 'data:%s;base64,%s'; return sprintf($fmt, $params['mime'], base64_encode(file_get_contents($path))); } }