October CMS media finder

1.9k Views Asked by At

I have recently created a plugin (using the 'builder plugin') where I have a field for attaching images (using 'media finder widget'). Everything is working fine - I can upload an image or choose one from the media library. After successful saving, when I go back to the recently saved record, the image isn't shown... How can I fix this?

Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

'media finder widget' not working with relation type 'file attachment', like this:

public $attachOne = [
   'avatar' => 'System\Models\File'
];

try to use another type (for example: json)

3
On

From what I found the media finder doesn't save the image in a relationship but records the URL of the image from the media library, this is why using:

public $attachOne = [
   'avatar' => 'System\Models\File'
];

Doesn't work. you actually have to add a field in the DB to record the image path.

If someone else has a better solution go with them, but this allowed me to keep the image.