Custom $form_fields not appearing in Attachment Details when uploading new img
-
Hi, so I’m running into an edge case where I have custom fields in my attachment details, and they are not appearing on the initial upload of a new image. I’m using the (‘attachment_fields_to_edit’) filter, and can confirm the data is all there. If I select another image and then go back to the one I uploaded it renders, just not on the first go.
I’ve been able to trace it down to this line in the media-view.js, where I’m checking to see if the compat.item exists, and for some reason it’s empty at the time of initial render.
Fyi, the Select Image Box I’m using is from a custom CMB2 File_List type field, but I don’t know if that makes any difference.
I did notice in other media modals, such as the single Select Image, that If I upload an image, the data doesn’t appear immediately, but does eventually show up, so It makes me think there is a render update that happens there.
Any ideas would be super helpful.Thank you!
/** * @return {wp.media.view.AttachmentCompat} Returns itself to allow chaining. */ render: function() { console.log('Rendering AttachmentCompat view'); // Debug statement var compat = this.model.get('compat'); if (!compat || !compat.item) { console.log('No compat or compat.item found'); // Debug statement return; } this.views.detach(); this.$el.html(compat.item); this.views.render(); console.log('AttachmentCompat view rendered successfully'); // Debug statement return this; },
- You must be logged in to reply to this topic.