@php $items = []; foreach ($media as $m) { $raw = trim($m->path ?? ''); $url = null; if ($raw !== '') { if (preg_match('~^https?://~i', $raw)) $url = $raw; elseif (str_starts_with($raw,'public/storage/')) { $p = substr($raw,7); if (file_exists(public_path($p))) $url = asset($p); } elseif (str_starts_with($raw,'storage/')) { if (file_exists(public_path($raw))) $url = asset($raw); } else { if (\Storage::disk('public')->exists($raw)) $url = \Storage::url($raw); elseif (file_exists(public_path($raw))) $url = asset($raw); } } $items[] = ['id'=>$m->id,'url'=>$url ?: asset('img/placeholder_zapato_detalle.svg'),'is_primary'=>(bool)$m->is_primary]; } @endphp
@foreach($items as $i => $it)
thumb
@endforeach
imagen