diff --git a/src/View/Components/Avatar.php b/src/View/Components/Avatar.php index b099a567a2..e64fbd653b 100644 --- a/src/View/Components/Avatar.php +++ b/src/View/Components/Avatar.php @@ -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, [ diff --git a/src/helpers.php b/src/helpers.php index 8596f21393..301fb32643 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -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; }