nova-menu-builder icon indicating copy to clipboard operation
nova-menu-builder copied to clipboard

getFields stores Image Field type as empty [] in the data field

Open radovanobal opened this issue 3 years ago • 3 comments

When saving a custom Image field, the image gets stored as an empty array json instead of the uploaded file.

radovanobal avatar Nov 17 '20 04:11 radovanobal

Ah yes, the Nova image field sucks quite a bit. I'm not too sure if we'll ever get it working with nova-menu-builder. For now, you could try any of the media libraries available that upload the image asynchronously (ie optimistdigital/nova-media-field).

Tarpsvo avatar Nov 17 '20 13:11 Tarpsvo

@Tarpsvo Doing this will create an array with the media ID in the data attributes. How do you retrieve the actual url, path or filename? I can't find docs about this in optimistdigital/nova-media-field

Pondake avatar Aug 10 '21 13:08 Pondake

The images are stored in a separate table. You can just query them using Media::find($mediaId) or Media::findMany($mediaIds). When you get the media model, you can just gets its url like so: $media->url.

Tarpsvo avatar Aug 10 '21 13:08 Tarpsvo