| Current Path : /var/www/html/reddsis/app/Helpers/ |
| Current File : /var/www/html/reddsis/app/Helpers/ImageHelper.php |
<?php
if (!function_exists('image_url')) {
/**
* Resolve an image URL. If the value is empty, returns the default
* "No Image Available" placeholder instead of picsum/external URLs.
*
* @param string|null $value
* @param string|null $default
* @return string
*/
function image_url($value, $default = null)
{
$default = $default ?? 'dynaweb4/img/No_Image_Available.jpg';
if (empty($value)) {
return asset($default);
}
if (str_starts_with($value, 'http')) {
return $value;
}
if (str_starts_with($value, 'dynaweb4/')) {
return asset($value);
}
return \Illuminate\Support\Facades\Storage::url($value);
}
}