1

I'm trying to open the Attachment Details popup, but with this code it shows all the images

jQuery(document).ready(function($){
    $( '.attachments' ).on( 'click', '.attachment', function( event ) {
                var $el = $( this );
                var selected = $( this ).attr( 'data-id' );

                //alert(selected);
                event.preventDefault();

                console.log(wp.media);
                // Create the media frame.
                gallery_items_frame = wp.media.frames.gallery_items = wp.media({
                    title: $el.data( 'choose' ),
                    button: {
                        text: $el.data( 'update' )
                    },
                    states: [
                        new wp.media.controller.Library({
                            title: $el.data( 'choose' ),
                            multiple: false,
                            selection: 'single',
                            contentUserSetting: true
                        })
                    ]
                });

                // Select the attachment when the frame opens
                gallery_items_frame.on( 'open', function() {
                    var selection = gallery_items_frame.state().get( 'selection' );
                    selection.reset( selected ? [ wp.media.attachment( selected ) ] : [] ); 
                });

                // Open the modal.
                gallery_items_frame.open();
            });
        });

This opens the "Media Library" successfully, but what I'm looking for is the "Attachment Details" where it shows just one image and the details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.