advanced-nova-media-library
advanced-nova-media-library copied to clipboard
Can't have a single image upload anymore?
Hello,
I'm struggling to make this package work on lastest version of Laravel and Nova. Basically I created a field where users can upload one image but looks like the field still display the button "Add new media" under my image.
- Laravel version: 8.9
- Nova version: 3.12.1
- ANML version: 3.3.0
Here my field:
Images::make('Image', 'image')
->conversionOnIndexView('thumb')
->croppingConfigs(['ratio' => 500 / 330]),
Here's my model:
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\InteractsWithMedia;
class SomeModel extends Model implements HasMedia
{
use InteractsWithMedia;
...
public function registerMediaConversions(Media $media = null): void
{
$this->addMediaConversion('thumb')
->width(500)
->height(330);
}
}
And here's a preview of my field:
Might be related to #117 but the singleFile()
method doesn't work anymore on Spatie's Laravel medialibrairie v8 :/
Add a collection with single file.
Like this
public function registerMediaCollections(): void
{
$this->addMediaCollection('image')
->singleFile();
}
You can only add one file but it still display "Add New Media" / "Upload New Media".
Thanks @bcoelhonqda but it doesn't work. Any way to make this work like before and don't add the "Add new media" button for single medias?
Similar problems here. There doesn't seem to be a way to prevent the user from adding more than one file through the media library field.
You can put a validation rule on the field, e.g. ->rules('nullable', 'max:1')
, and that will prevent the form from submitting when multiple files are chosen, however, no validation error is displayed.
@stuartcusackie yeah unfortunately that's more a "workaround" than a real fix :( Btw I've updated all my dependencies to latest versions from spatie and still have the same issue
same issue here
Issue does not happen to me:
spatie/laravel-medialibrary:10.3.2 laravel/framework:9.9.0 laravel/nova:4.2.5
Any update on a fix for this?
Any solution?