Skip to content

Commit 1723eff

Browse files
asset('path') name changed to tasset('path')
1 parent 413372f commit 1723eff

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Tame.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,19 +941,30 @@ static public function readPDFToBrowser($path = null)
941941
/**
942942
* Convert image to base64
943943
*
944-
* @param string|null $path
944+
* @param string|null $path
945945
* - [base path will be automatically added]
946946
*
947+
* @param bool $url
948+
* - [If path should be treated as direct url]
949+
*
947950
* @return null|string
948951
*/
949-
static public function imageToBase64($path = null)
952+
static public function imageToBase64($path = null, $direct = false)
950953
{
951954
$fullPath = self::getBasePath($path);
952955

953-
if(self::exists($fullPath)){
954-
$type = pathinfo($fullPath, PATHINFO_EXTENSION);
955-
$data = file_get_contents($fullPath);
956+
if($direct){
957+
// Parse the URL to get the path
958+
$parse = parse_url($path, PHP_URL_PATH);
959+
$type = pathinfo($parse, PATHINFO_EXTENSION);
960+
$data = @file_get_contents($path);
961+
} else{
962+
$type = pathinfo($fullPath, PATHINFO_EXTENSION);
963+
$data = @file_get_contents($fullPath);
964+
}
956965

966+
// if true
967+
if($data){
957968
return 'data:image/' . $type . ';base64,' . base64_encode($data);
958969
}
959970
}

Time.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ public function __format(int|string $date)
118118
*/
119119
static public function timestamp($date, $format = "Y-m-d H:i:s")
120120
{
121-
if(is_string($date)){
122-
$date = strtotime($date);
123-
}
121+
$date = TimeHelper::setPassedDate($date);
124122

125123
return !is_bool($date) ? date($format, $date) : '';
126124
}

helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function env_update($key = null, $value = null, ?bool $quote = true, ?bool $spac
269269
}
270270
}
271271

272-
if (! function_exists('asset')) {
272+
if (! function_exists('tasset')) {
273273
/**
274274
* Create assets Real path url
275275
*
@@ -280,7 +280,7 @@ function env_update($key = null, $value = null, ?bool $quote = true, ?bool $spac
280280
*
281281
* @return string
282282
*/
283-
function asset($asset = null, $cache = null)
283+
function tasset($asset = null, $cache = null)
284284
{
285285
return Asset::asset($asset, $cache);
286286
}

0 commit comments

Comments
 (0)