{{----}}
@php
function getImageWithPrefix($images, $prefixToCheck, $fallbackPrefix, $extension) {
$selectedImage = null;
// Loop through the array to find the desired image with the specified prefix and extension
foreach ($images as $image) {
// Check for the desired prefix and extension
if (strpos($image, $prefixToCheck) !== false && strpos($image, $extension) !== false) {
$selectedImage = $image;
break;
}
}
// If the desired image is not found, look for the fallback prefix
if (!$selectedImage) {
foreach ($images as $image) {
if (strpos($image, $fallbackPrefix) !== false) {
$selectedImage = $image;
break;
}
}
}
return $selectedImage;
}
@endphp