Upgrading | laravel-medialibrary-pro | Spatie

 SPATIE

laravel-medialibrary-pro
========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-medialibrary-pro](https://spatie.be/docs/laravel-medialibrary-pro/v6)  Upgrading

 Version   v6

 Other versions for crawler [v6](https://spatie.be/docs/laravel-medialibrary-pro/v6)

- [ Introduction ](https://spatie.be/docs/laravel-medialibrary-pro/v6/introduction)
- [ Requirements ](https://spatie.be/docs/laravel-medialibrary-pro/v6/requirements)
- [ License ](https://spatie.be/docs/laravel-medialibrary-pro/v6/license)
- [ Getting help ](https://spatie.be/docs/laravel-medialibrary-pro/v6/getting-help)
- [ Upgrading ](https://spatie.be/docs/laravel-medialibrary-pro/v6/upgrading)
- [ About us ](https://spatie.be/docs/laravel-medialibrary-pro/v6/about-us)
- [ ](https://spatie.be/docs/laravel-medialibrary-pro/v6/demo-application)

Blade
-----

- [ Installation ](https://spatie.be/docs/laravel-medialibrary-pro/v6/blade/installation)
- [ Usage ](https://spatie.be/docs/laravel-medialibrary-pro/v6/blade/usage)

Livewire
--------

- [ Installation ](https://spatie.be/docs/laravel-medialibrary-pro/v6/livewire/installation)
- [ Attachments ](https://spatie.be/docs/laravel-medialibrary-pro/v6/livewire/attachments)
- [ Collection ](https://spatie.be/docs/laravel-medialibrary-pro/v6/livewire/collection)
- [ Uploading to S3 ](https://spatie.be/docs/laravel-medialibrary-pro/v6/livewire/uploading-to-s3)

React
-----

- [ Installation ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/installation)
- [ Usage ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/usage)
- [ Available props ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/available-props)
- [ Inertia ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/inertia)
- [ Next.js ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/nextjs)
- [ Translations ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/translations)
- [ Vapor support ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/vapor)
- [ Creating custom components ](https://spatie.be/docs/laravel-medialibrary-pro/v6/react/creating-custom-components)

Vue.js
------

- [ Installation ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/installation)
- [ Usage ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/usage)
- [ Available props ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/available-props)
- [ Inertia ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/inertia)
- [ Translations ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/translations)
- [ Vapor support ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/vapor)
- [ Creating custom components ](https://spatie.be/docs/laravel-medialibrary-pro/v6/vue/creating-custom-components)

Security
--------

- [ Authorisation ](https://spatie.be/docs/laravel-medialibrary-pro/v6/security/authorisation)
- [ Configure allowed mime types ](https://spatie.be/docs/laravel-medialibrary-pro/v6/security/allowed-mime-types)
- [ Rate limiting ](https://spatie.be/docs/laravel-medialibrary-pro/v6/security/rate-limiting)

Advanced
--------

- [ Customizing CSS ](https://spatie.be/docs/laravel-medialibrary-pro/v6/advanced/customizing)
- [ Customize the preview images ](https://spatie.be/docs/laravel-medialibrary-pro/v6/advanced/custom-preview-images)
- [ Customize the upload URL ](https://spatie.be/docs/laravel-medialibrary-pro/v6/advanced/customiz-upload-url)
- [ Usage in a frontend repository ](https://spatie.be/docs/laravel-medialibrary-pro/v6/advanced/usage-in-a-frontend-repository)

Legacy
------

- [ Livewire 2 ](https://spatie.be/docs/laravel-medialibrary-pro/v6/legacy/livewire-2)
- [ Laravel Mix ](https://spatie.be/docs/laravel-medialibrary-pro/v6/legacy/laravel-mix)

 Upgrading
=========

###  On this page

1. [ Upgrading ](#content-upgrading)
2. [ From v4/v5 to v6 ](#content-from-v4v5-to-v6)
3. [ From v3 to v4 ](#content-from-v3-to-v4)
4. [ From v2 to v3 ](#content-from-v2-to-v3)
5. [ From v1 to v2 ](#content-from-v1-to-v2)

Upgrading
-----------------------------------------------------------------------------------

This file contains instructions on how to upgrade to another major version of the package.

From v4/v5 to v6
------------------------------------------------------------------------------------------------------

- The directive `@mediaLibraryStyles` now also includes the default CSS. If you only want to include the CSS in an other way you should use `@mediaLibraryIcons` instead.

From v3 to v4
-----------------------------------------------------------------------------------------------

The main change in v4 is that we upgraded the required version of Media Library from v10 to v11. Under the hood spatie/image v3 is used instead of v2.

In the latest version of spatie/image some of the manipulations methods have been renamed. If you're using any of these methods in your code, you'll need to update them. Take a look at the [defining conversions page](/docs/laravel-medialibrary/v11/converting-images/defining-conversions) to learn more.

From v2 to v3
-----------------------------------------------------------------------------------------------

The main change in v3 is that we now use Livewire 3.0 instead of Livewire 2.0. If you're using the JavaScript component, then there are no breaking changes.

### Update the Livewire version requirement to v3:

```
-        "livewire/livewire": "^2.0",
+        "livewire/livewire": "^v3.0",
```

### Add the Blade directives to your views

```
-
-
-
+ @mediaLibraryStyles

+ @mediaLibraryScripts
```

### Update usage of the `WithMedia` trait:

```
- use Spatie\MediaLibraryPro\Http\Livewire\Concerns\WithMedia;
+ use Spatie\MediaLibraryPro\Livewire\Concerns\WithMedia;
```

### `clearMedia` has been removed

The `->clearMedia()` method has been removed from the trait. Since you can now use model binding you can set your collection back to an empty array if you need to clear your media.

```
public function submit()
{
    // submit the form

-    $this->clearMedia();
+    $this->media = [];
}
```

### Make sure you're setting your media properties to a default empty array

```
-    public $media;
+    public $media = [];
```

### The `$mediaComponentNames` property has been removed in favour of Livewire model binding.

```
- public $mediaComponentNames = ['images', 'downloads'];

public $images = [];

public $downloads = [];
```

### Use the Livewire components directly instead of the Blade components

We now have 1 Livewire component that can handle both Attachment and Collection use cases, use this Livewire component directly instead of using the provided Blade component.

If you're not using Livewire yourself, you can still use the Blade components like before.

#### Attachment

```
-
 +
```

#### Collection

```
-
+
```

From v1 to v2
-----------------------------------------------------------------------------------------------

No changes to the public API were made. Support for PHP 7 and Laravel 8 was dropped.

You should be able to upgrade without making any changes.
