Support » Everything else WordPress » 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 {} 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
    		console.log('AttachmentCompat view rendered successfully'); // Debug statement
    		return this;
Viewing 1 replies (of 1 total)
  • Thread Starter ogdsgn


    Here’s a snag right after uploading the image. You can see the compat-item data is missing

    And then if I click off the image and re-select it magically appears.

    • This reply was modified 5 days, 12 hours ago by ogdsgn.
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.