This is the documentation for
v3 but the latest version is
v11
.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/laravel-medialibrary
When adding a file to the medialibrary you can pass an array with custom properties:
$mediaItem = $newsItem
->addMedia($pathToFile)
->withCustomProperties(['mime-type' => 'image/jpeg'])
->toMediaLibrary();
v3.3+ There are some convenience methods to work with custom properties:
$mediaItem->hasCustomProperty('mime-type');
$mediaItem->getCustomProperty('mime-type');
$mediaItem->hasCustomProperty('does not exists');
$mediaItem->getCustomProperty('does not exists');
v3.5+ You can also specify a default value when retrieving a custom property.
$mediaItem->getCustomProperty('isPublic', false);