diff --git a/src/LightboxDisplayer.php b/src/LightboxDisplayer.php index da41d5e..8c0f0b9 100644 --- a/src/LightboxDisplayer.php +++ b/src/LightboxDisplayer.php @@ -28,7 +28,7 @@ public function zooming() 'zoom' => [ 'enabled' => true, 'duration' => 300, - 'easing' => 'ease-in-out', + 'easing' => 'ease-in-out', ] ]); } @@ -39,6 +39,10 @@ public function display(array $options = []) return ''; } + if ($this->value instanceof Arrayable) { + $this->value = $this->value->toArray(); + } + $server = array_get($options, 'server'); $width = array_get($options, 'width', 200); $height = array_get($options, 'height', 200); @@ -49,18 +53,20 @@ public function display(array $options = []) Admin::script($this->script()); - if (url()->isValidUrl($this->value)) { - $src = $this->value; - } elseif ($server) { - $src = rtrim($server, '/') . '/' . ltrim($this->value, '/'); - } else { - $src = Storage::disk(config('admin.upload.disk'))->url($this->value); - } + return collect((array)$this->value)->filter()->map(function ($path) use ($server, $width, $height) { + if (url()->isValidUrl($path) || strpos($path, 'data:image') === 0) { + $src = $path; + } elseif ($server) { + $src = rtrim($server, '/') . '/' . ltrim($path, '/'); + } else { + $src = Storage::disk(config('admin.upload.disk'))->url($path); + } - return << HTML; + })->implode(' '); } -} \ No newline at end of file +}