• Resolved ogdsgn

    (@ogdsgn)


    I’m having a weird edge case I could use some help to debug.

    I have some post_meta on my attachments, and in almost every instance of the Media Modal it instantiates and saves fine, however, when opening the Add/Upload Media Window from a CMB2 File_List, and using the Upload Files tab, the custom post_meta doesn’t always show up consistently.

    After the image is uploaded I can click another image, and then back to the image I uploaded and then it appears.

    I’ve tried playing with the priority of the ‘attachment_fields_to_edit’ filter to no success.

    It feels like it must be an order of operations issue, but I just can’t track down where this would be occuring.

    any help would be super appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Honestly not sure what may be going on here, since I don’t know how well or efficiently CMB2 would be able to be used with regards to adding metaboxes to media library items. That’s always been an odd space in general to add meta data to.

    Posts, terms, users, and option pages, no problem. The attachment post type…hrm.

    Thread Starter ogdsgn

    (@ogdsgn)

    Hey Michael,

    Doh, I just realized I’m not actually placing CMB2 fields in that media modal. I just happened to place the code for it in my CMB2 meta boxes file, but after taking a closer look I’m actually using the native $form_fields and the add_filter(‘attachment_fields_to_edit’). Sorry for thinking it might be CMB2.

    Thanks for your time.
    – Stephen

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    All good.

    Thread Starter ogdsgn

    (@ogdsgn)

    Time to dive into WP source code. media.php here we go……

    Thread Starter ogdsgn

    (@ogdsgn)

    For anyone interested… I’ve pinpointed the issue down to here.

    This is the render function for the Attachment details in the media-view.js

    For some reason the compat.item is not available at this point when I upload a new file through this media uploader.

    	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(compat.item); // Debug statement
    		return this;
    	},
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Media Modal issue when opened using type file_list’ is closed to new replies.