diff --git a/Tame.php b/Tame.php index 4979361..1d47b15 100644 --- a/Tame.php +++ b/Tame.php @@ -941,19 +941,30 @@ static public function readPDFToBrowser($path = null) /** * Convert image to base64 * - * @param string|null $path + * @param string|null $path * - [base path will be automatically added] * + * @param bool $url + * - [If path should be treated as direct url] + * * @return null|string */ - static public function imageToBase64($path = null) + static public function imageToBase64($path = null, $direct = false) { $fullPath = self::getBasePath($path); - if(self::exists($fullPath)){ - $type = pathinfo($fullPath, PATHINFO_EXTENSION); - $data = file_get_contents($fullPath); + if($direct){ + // Parse the URL to get the path + $parse = parse_url($path, PHP_URL_PATH); + $type = pathinfo($parse, PATHINFO_EXTENSION); + $data = @file_get_contents($path); + } else{ + $type = pathinfo($fullPath, PATHINFO_EXTENSION); + $data = @file_get_contents($fullPath); + } + // if true + if($data){ return 'data:image/' . $type . ';base64,' . base64_encode($data); } } diff --git a/Time.php b/Time.php index e3251df..eebeb4f 100644 --- a/Time.php +++ b/Time.php @@ -118,9 +118,7 @@ public function __format(int|string $date) */ static public function timestamp($date, $format = "Y-m-d H:i:s") { - if(is_string($date)){ - $date = strtotime($date); - } + $date = TimeHelper::setPassedDate($date); return !is_bool($date) ? date($format, $date) : ''; } diff --git a/helpers.php b/helpers.php index 2ea0c1c..d6d3785 100644 --- a/helpers.php +++ b/helpers.php @@ -269,7 +269,7 @@ function env_update($key = null, $value = null, ?bool $quote = true, ?bool $spac } } -if (! function_exists('asset')) { +if (! function_exists('tasset')) { /** * Create assets Real path url * @@ -280,7 +280,7 @@ function env_update($key = null, $value = null, ?bool $quote = true, ?bool $spac * * @return string */ - function asset($asset = null, $cache = null) + function tasset($asset = null, $cache = null) { return Asset::asset($asset, $cache); }