@props([ 'label' => null, 'hint' => null, 'existing' => null, 'existingWire' => null, 'file' => null, 'accept' => 'image/jpeg,image/png,image/webp,image/gif', 'height' => 'h-44', 'required' => false, ]) @php $wireModel = $attributes->wire('model')->value(); $name = $attributes->get('name', $wireModel ?: 'image'); $id = $attributes->get('id', 'upload_' . ($wireModel ?: 'img_') . uniqid()); // Auto-detect existing wire property if not specified (e.g. ogImage -> existingOgImageUrl) if (!$existingWire && $wireModel) { $existingWire = 'existing' . ucfirst($wireModel) . 'Url'; } // Determine initial preview URL: uploaded temp file > existing URL $initialPreview = ''; if ($file && method_exists($file, 'temporaryUrl')) { try { $initialPreview = $file->temporaryUrl(); } catch (\Throwable $e) { $initialPreview = ''; } } elseif ($existing) { $initialPreview = $existing; } @endphp
Click to upload or drag and drop
PNG, JPG, WebP or GIF (Up to 2MB)
{{ $hint }}
@endif @if ($wireModel) @error($wireModel){{ $message }}
@enderror @endif