<?php
use function App\Core\e;

$id = $id ?? 'image-grid';
$images = $images ?? [];
?>
<div class="image-preview-grid" data-image-grid="<?= e($id) ?>">
    <?php foreach ($images as $index => $image): ?>
        <?php $path = (string) ($image['image_path'] ?? $image['src'] ?? $image); ?>
        <?php if ($path === '') continue; ?>
        <div class="image-preview-item" draggable="true" data-existing-image>
            <img src="<?= e($path) ?>" alt="">
            <input type="hidden" name="existing_gallery[]" value="<?= e($path) ?>">
            <span><?= (int) $index + 1 ?></span>
            <button type="button" data-remove-preview>Sil</button>
        </div>
    <?php endforeach; ?>
</div>
