Skip to content

Commit a19772d

Browse files
authored
Merge pull request #6 from jxlwqq/patch-2
add img class option.
2 parents b4b2e4e + d8c1b88 commit a19772d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ $grid->picture()->gallery(['zooming' => true]);
4848
//width & height properties
4949
$grid->picture()->lightbox(['width' => 50, 'height' => 50]);
5050
$grid->picture()->gallery(['width' => 50, 'height' => 50]);
51+
52+
//img class properties
53+
$grid->picture()->lightbox(['class' => 'rounded']);
54+
$grid->picture()->gallery(['class' => ['circle', 'thumbnail']]);
5155
```
5256

5357
## Donate

src/LightboxDisplayer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ public function display(array $options = [])
4646
$server = array_get($options, 'server');
4747
$width = array_get($options, 'width', 200);
4848
$height = array_get($options, 'height', 200);
49+
$class = array_get($options, 'class', 'thumbnail');
50+
$class = collect((array)$class)->map(function ($item) {
51+
return 'img-'. $item;
52+
})->implode(' ');
4953

5054
if (array_get($options, 'zooming')) {
5155
$this->zooming();
5256
}
5357

5458
Admin::script($this->script());
5559

56-
return collect((array)$this->value)->filter()->map(function ($path) use ($server, $width, $height) {
60+
return collect((array)$this->value)->filter()->map(function ($path) use ($server, $width, $height, $class) {
5761
if (url()->isValidUrl($path) || strpos($path, 'data:image') === 0) {
5862
$src = $path;
5963
} elseif ($server) {
@@ -64,7 +68,7 @@ public function display(array $options = [])
6468

6569
return <<<HTML
6670
<a href="$src" class="grid-popup-link">
67-
<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img img-thumbnail' />
71+
<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img {$class}' />
6872
</a>
6973
HTML;
7074
})->implode('&nbsp;');

0 commit comments

Comments
 (0)