Skip to content

Commit 51a5e73

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 2411dea + 33f3497 commit 51a5e73

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Media/AllowedMimeTypes.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,30 @@ public static function getAttachmentValidationRule(string|array|null $type = nul
599599
return $rules;
600600
}
601601

602+
/**
603+
* Convert accept string to extensions string
604+
*
605+
* @param $accept
606+
* @param string $separator
607+
* @return string
608+
*/
609+
public static function acceptToExtensions($accept, string $separator = ', '): string
610+
{
611+
$mime_types = to_array($accept, ',', true);
612+
613+
$extensions = [];
614+
615+
foreach ($mime_types as $mime) {
616+
if ($ext = self::getExtension($mime)) {
617+
$extensions[] = $ext;
618+
}
619+
}
620+
621+
$extensions = array_unique($extensions);
622+
623+
return implode($separator, $extensions);
624+
}
625+
602626
/**
603627
* Get the the extension for the mime type
604628
*

0 commit comments

Comments
 (0)