nova-medialibrary-field icon indicating copy to clipboard operation
nova-medialibrary-field copied to clipboard

Add `->defaultCollection()`

Open bilogic opened this issue 4 years ago • 1 comments

Hi,

The issue is that on the frontend blade, ->getMediaUrl() does not work unless a collection name is provided.

This is because Spatie uses default as collection name if one is not specified. However, this package will use 'name' from ::make('name'), and I understand why.

My suggestion is to add ->defaultCollection() to prevent this package from using 'name'. This will then allow getMedialUrl() to work like described in medialibrary's docs.

I prefer not to write ::make('name', 'default') because it is less readable and can cause confusion for those who are new to medialibrary and we can document the purpose of defaultCollection() since it is a function.

Thank you.

bilogic avatar Aug 25 '21 12:08 bilogic

@bilogic Good point. I'll add that method.

dmitrybubyakin avatar Aug 25 '21 12:08 dmitrybubyakin