Components
Media Library
Integrations
File types
By default, the Media Library only accepts image uploads. However, you are free to allow more file types into your library using the below helpers.
The Media Library will show previews for those file types that it can generate previews for (such as images, and PDFs when using the "spatie/pdf-to-image" package). Other file types will show using a sensible icon.
Note that this only applies to new uploads. Any existing files that might not match the accepted types will still appear.
Images
By default, images are allowed to be uploaded. You can disable this by passing false to the ->acceptImage() method:
To accept only a specific subset of image types, use ->acceptImage(false) and use the ->additionalAcceptedFileTypes() method below to enable these specific types.
PDFs
To enable PDF uploads, use the ->acceptPdf() method:
Note: In order to upload PDFs, you need to have the "spatie/pdf-to-image" package configured correctly. This package is already required via Composer if you are using Spatie Media Library, but you need to make sure that the extension for imagick has been installed and that Ghostscript is installed. Check out the requirements.
Videos
To enable video uploads, use the ->acceptVideo() method:
Note: In order to let your users upload videos, you need to have the FFmpeg binary installed. See the FFmpeg website for installation instructions. You also need to install the
php-ffmpeg/php-ffmpegpackage and update the value of the configmedia-library.ffmpeg_pathandmedia-library.ffmpeg_probe.
Audio files
To enable audio file uploads, use the ->acceptAudio() method:
This accepts all audio types including .mp3, .wav, .flac and other common formats.
ZIP archives
To enable ZIP file uploads, use the ->acceptZip() method:
This accepts both .zip files and other ZIP-compressed formats.
Microsoft Office documents
The Media Library provides convenient methods for accepting Microsoft Office documents:
Microsoft Word
To accept Word-documents (.doc and .docx), use the ->acceptMicrosoftWord() method:
Microsoft PowerPoint
To accept PowerPoint-presentations (.ppt and .pptx), use the ->acceptMicrosoftPowerPoint() method:
Microsoft Excel
To accept Excel-spreadsheets (.xls and .xlsx), use the ->acceptMicrosoftExcel() method:
CSV files
To enable CSV file uploads, use the ->acceptCsv() method:
Custom file types
For file types not covered by the built-in methods, you can specify additional accepted file types using MIME types:
Single file type
Multiple file types
In all cases, the library will fall back to an icon for file types it cannot generate previews for.