问题
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!
回答1:
'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)
回答2:
Try to see this video
Maybe she can help you
回答3:
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.
来源:https://stackoverflow.com/questions/47078147/october-cms-media-finder