@props([ 'arrayName', 'column', 'prefixName' => '', 'values' => [], 'maxImages' => 5, 'allowedExtensions' => ['jpg', 'jpeg', 'png', 'gif'], 'maxFileSize' => 10 * 1024 * 1024, // 10MB 'recommendedSize' => '', ]) @php $arrayName = empty($prefixName) ? $arrayName : `{$prefixName}[{$arrayName}]`; $isDisabled = (bool) $attributes->get('disabled'); // 初期値の準備 $initialImages = old(dot_name($arrayName)) ?: []; if (empty($initialImages)) { $initialImages = []; foreach ($values as $index => $value) { $image = is_array($value) ? $value['image'] ?? '' : $value; $imageUrl = is_array($value) ? $value['image_url'] ?? '' : ''; $alt = is_array($value) ? $value['alt'] ?? '' : ''; if (!empty($image)) { $initialImages[] = [ 'image' => $image, 'image_url' => $imageUrl, 'alt' => $alt, ]; } } } // 推奨サイズからアスペクト比を算出("WxH" 形式) $cropAspectRatio = 0; if (!empty($recommendedSize) && preg_match('/^(\d+)\s*x\s*(\d+)$/i', $recommendedSize, $matches)) { $cropWidth = (int) $matches[1]; $cropHeight = (int) $matches[2]; if ($cropHeight > 0) { $cropAspectRatio = $cropWidth / $cropHeight; } } // 拡張子をaccept属性用の形式に変換 $acceptExtensions = array_map(fn($ext) => '.' . strtolower($ext), $allowedExtensions); $acceptAttribute = implode(',', $acceptExtensions); @endphp {{-- 複数画像アップローダー --}}
画像の上限数(枚)に達しました
対応形式: {{ implode(', ', $allowedExtensions) }}
最大ファイルサイズ: {{ $maxFileSize / 1024 / 1024 }}MB (1枚あたり)
@if ($recommendedSize)推奨pxサイズ: {{ $recommendedSize }}
@endif※200文字以内で入力してください