Adding custom properties

When adding a file to the medialibrary you can pass an array with custom properties:

$mediaItem = $newsItem
    ->withCustomProperties(['mime-type' => 'image/jpeg'])

v3.3+ There are some convenience methods to work with custom properties:

$mediaItem->hasCustomProperty('mime-type'); // returns true
$mediaItem->getCustomProperty('mime-type'); // returns 'image/jpeg'

$mediaItem->hasCustomProperty('does not exists'); // returns false
$mediaItem->getCustomProperty('does not exists'); // returns null

v3.5+ You can also specify a default value when retrieving a custom property.

$mediaItem->getCustomProperty('isPublic', false);