mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
move absolute URL check to get_image_url() function
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace Filament\View\Components;
|
||||
|
||||
use Filament\Filament;
|
||||
use Illuminate\Support\Str;
|
||||
use function Filament\get_image_url;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
@@ -35,10 +34,6 @@ class Avatar extends Component
|
||||
return Filament::avatarProvider()->get($this->user, $this->size, $dpr);
|
||||
}
|
||||
|
||||
if (Str::startsWith($avatar, ['http://', 'https://'])) {
|
||||
return $avatar;
|
||||
}
|
||||
|
||||
return get_image_url(
|
||||
$avatar,
|
||||
[
|
||||
|
||||
+8
-1
@@ -59,6 +59,13 @@ if (! function_exists('Filament\get_asset_id')) {
|
||||
if (! function_exists('Filament\get_image_url')) {
|
||||
function get_image_url($path, $manipulations = [])
|
||||
{
|
||||
if (
|
||||
Str::startsWith($path, ['http://', 'https://'])
|
||||
&& filter_var($path, FILTER_VALIDATE_URL)
|
||||
) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$urlBuilder = UrlBuilderFactory::create('', config('app.key'));
|
||||
|
||||
return route('filament.image', ['path' => ltrim($urlBuilder->getUrl($path, $manipulations), '/')]);
|
||||
@@ -69,7 +76,7 @@ if (! function_exists('Filament\get_media_contents')) {
|
||||
function get_media_contents($path)
|
||||
{
|
||||
$disk = Storage::disk(config('filament.default_filesystem_disk'));
|
||||
|
||||
|
||||
if (! $disk->exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user