This is the documentation for
v9 but the latest version is
v10
.
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
A media conversion can be added to your model in the registerMediaConversions
-function. It should start with a call to addMediaConversion
. From there on you can use any of the methods available in the API. They are all chainable.
Take a look in the Defining conversions section
for more details.
##General methods
##addMediaConversion
/*
* Add a conversion.
*/
public function addMediaConversion(string $name): \Spatie\MediaLibrary\Conversions\Conversion
##performOnCollections
/*
* Set the collection names on which this conversion must be performed.
*
* @param string $collectionNames,...
*/
public function performOnCollections($collectionNames): self
##queued
/*
* Mark this conversion as one that should be queued.
*/
public function queued(): self
##nonQueued
/*
* Mark this conversion as one that should not be queued.
*/
public function nonQueued(): self
##useLoadingAttributeValue
This is the value that, when this conversation is converted to html, will be used in the loading
attribute. The loading attribute is a standardised attribute that controls lazy loading behaviour of the browser. Possible values are lazy
, eager
, auto
or null if you don't want to set any loading instruction.
You can learn more on native lazy loading in this post on css-tricks.
##Image manipulations
You may add any call to one of the manipulation functions available on the spatie/image package.