Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function smarty_modifier_inline_image($url)
// $urlを内部パスに置き換える
$path = str_replace(XOOPS_URL , XOOPS_ROOT_PATH, $url);
if(strpos($path, XOOPS_ROOT_PATH) === false){
// 内部パスに置き換えられなければ元のURLを返す
return $url;
$img = base64_encode(file_get_contents($path));
$finfo = finfo_open(FILEINFO_MIME);
$mime = finfo_file($finfo, $path);
$src = 'data:' . $mime. ';base64,'.$img;
return $src;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.