Skip to content

Commit f2b8613

Browse files
committed
support parameters in hasMedia
1 parent 2eacfa0 commit f2b8613

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Traits/HasMedia.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,31 @@ public function hasMedia(?string $collection_name = null, ?string $collection_gr
7272
/**
7373
* @return TMedia
7474
*/
75-
public function getFirstMedia(?string $collection_name = null, ?string $collection_group = null)
76-
{
75+
public function getFirstMedia(
76+
?string $collection_name = null,
77+
?string $collection_group = null
78+
) {
7779
return $this->getMedia($collection_name, $collection_group)->first();
7880
}
7981

82+
/**
83+
* @param null|bool|string|array<int, string> $fallback
84+
*/
8085
public function getFirstMediaUrl(
8186
?string $collection_name = null,
8287
?string $collection_group = null,
8388
?string $conversion = null,
89+
null|bool|string|array $fallback = null,
90+
?array $parameters = null,
8491
): ?string {
8592
$media = $this->getFirstMedia($collection_name, $collection_group);
8693

8794
if ($media) {
88-
return $media->getUrl($conversion);
95+
return $media->getUrl(
96+
conversion: $conversion,
97+
fallback: $fallback,
98+
parameters: $parameters
99+
);
89100
}
90101

91102
$collection = $this->getMediaCollection($collection_name);

0 commit comments

Comments
 (0)