@if(str_starts_with($media->mime_type, 'image/'))
@php
// محاولة الحصول على الرابط بطرق مختلفة
$url = null;
$customProperties = $media->custom_properties ?? [];
if (isset($customProperties['path'])) {
$url = asset('storage/' . $customProperties['path']);
} else {
// محاولة استخدام getUrl إذا كان متاح
try {
$url = $media->getUrl();
} catch (\Exception $e) {
// إذا فشل، جرب البحث في المجلد الافتراضي
$possiblePaths = [
"media/{$media->id}/{$media->file_name}",
"media/{$media->file_name}",
$media->file_name
];
foreach ($possiblePaths as $path) {
if (Storage::disk('public')->exists($path)) {
$url = asset('storage/' . $path);
break;
}
}
}
}
@endphp
@if($url)

@else
{{ admin_trans('image_not_available') }}
{{ $media->file_name }}
@endif
@elseif(str_starts_with($media->mime_type, 'video/'))
{{ admin_trans('video_file') }}
{{ $media->file_name }}
@else
{{ admin_trans('document') }}
{{ $media->file_name }}
@endif
{{ admin_trans('filename') }}:
{{ $media->file_name }}
{{ admin_trans('size') }}:
{{ number_format($media->size / 1024, 1) }} KB
{{ admin_trans('element_type') }}:
{{ $media->mime_type }}
{{ admin_trans('upload_date') }}:
{{ $media->created_at->format('d/m/Y H:i') }}