Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 809 Bytes

file.mdx

File metadata and controls

55 lines (38 loc) · 809 Bytes

File

A WordPress media library file picker. Stores the attachment ID.


PHP API

Field::file(string $key): FileField

Type-specific methods

->returnFormat(string $format): static
Format Returns
'id' (default) int — attachment ID
'url' string — file URL
'array' array — ['id', 'url', 'name', 'mime']

Storage

{ "cv": 231 }

Example

Field::file('project_brief')
    ->label('Project Brief (PDF)')
    ->returnFormat('array'),

Template usage

@php $file = ctrlfield_get('project_brief') @endphp

@if($file)
    <a href="{{ $file['url'] }}" download>
        Download {{ $file['name'] }} ({{ strtoupper(last(explode('/', $file['mime']))) }})
    </a>
@endif