Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kvignos

    (@kvignos)

    More details about our attempts:

    First issue is that my Edit Gallery 1 link gets generated by the code in my original post as:

    <a href="#" class="media-menu-item">Edit Gallery 1</a>

    the class name (“media-menu-item”) is not unique, so if I add

    jQuery(document).on( 'click', '.media-menu-item', function( event ){
    		event.preventDefault();
    		wp.media.gallery.edit('[gallery ids="19580,19579,19578,19577,19576"]');
    	});

    I can get the gallery modal to open, but it breaks all the other media-menu-item element links (of course).

    How do I identify the “Edit Gallery 1” link so I can apply the on(‘click’) event to it? How can I add an id attribute, for instance?

    How do I get and pass the correct shortcode instead of having it hardcoded in wp.media.gallery.edit()? I tried playing around with wp.shortcode.string; but it’s not clear how to loop through and get each shortcode string and then set up the “Edit Gallery n” link (and then pass the correct shortcode).

    I have the exact same requirement. We need to edit galleries from text editor. Using the suggestion that Andrew made doesn’t work for editing an existing gallery.

    How can we provide a workaround to edit galleries from text mode?

    I’m trying to add new menu items for each gallery to the Insert Media modal, but it’s complicated since we need to grab each instance of the gallery shortcode (since there can be multiple galleries on a post), and then provide a link to the Edit Gallery modal.

    I know how to add a link to the Insert Media modal, but I’m not sure 1) how to set up a link for each gallery dynamically and 2) once that link is on the Insert Media menu item toolbar, how to open the Edit Gallery modal by passing the correct gallery ids.

    Thanks for any help anyone can provide!

Viewing 2 replies - 1 through 2 (of 2 total)