Skip to content

Commit 3b2873b

Browse files
feat: add support for custom image class in JSON media rendering
1 parent 719dbae commit 3b2873b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

resources/views/json-media/media.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="flex">
22
<figure class="w-full" >
3-
<img class="object-cover w-full" loading="lazy"
3+
<img class="object-cover w-full {{ $media->imgClass }}" loading="lazy"
44
src="{{ $media->getCropUrl(width: $media->width,height: $media->height) }}"
55
alt="{{ $media->getCustomProperty('alt') }}"
66
width="{{ $media->width }}"

src/JsonMedia/Media.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(
2424
protected array $content,
2525
public int $width = 250,
2626
public int $height = 180,
27+
public ?string $imgClass = null,
2728
) {
2829
$this->getDisk();
2930
}
@@ -85,10 +86,11 @@ public function getCustomProperty(string $property): mixed
8586
return $this->getContentKeyValue('customProperties.' . $property);
8687
}
8788

88-
public function withImageProperties(int $width, int $height): Media
89+
public function withImageProperties(int $width, int $height, ?string $imgClass = null): Media
8990
{
9091
$this->width = $width;
9192
$this->height = $height;
93+
$this->imgClass = $imgClass;
9294

9395
return $this;
9496
}

0 commit comments

Comments
 (0)