Created
December 14, 2015 23:59
-
-
Save RyujiAMANO/34d62e77afa0b9281675 to your computer and use it in GitHub Desktop.
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 | |
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