Skip to content

Commit

Permalink
asset('path') name changed to tasset('path')
Browse files Browse the repository at this point in the history
  • Loading branch information
tamedevelopers committed Jul 18, 2024
1 parent 413372f commit 1723eff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
21 changes: 16 additions & 5 deletions Tame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 1 addition & 3 deletions Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '';
}
Expand Down
4 changes: 2 additions & 2 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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);
}
Expand Down

0 comments on commit 1723eff

Please sign in to comment.