Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/LightboxDisplayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function zooming()
'zoom' => [
'enabled' => true,
'duration' => 300,
'easing' => 'ease-in-out',
'easing' => 'ease-in-out',
]
]);
}
Expand All @@ -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);
Expand All @@ -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
return <<<HTML
<a href="$src" class="grid-popup-link">
<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img img-thumbnail' />
</a>
HTML;
})->implode('&nbsp;');
}
}
}