Support » Plugins » Hacks » Need to edit galleries from text editor

  • We need to be able to edit previously created galleries from text editor. Our installation has the visual editor disabled because we’ve had problems with it eating posts (stripping content).

    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:

    Edit_my_gallery_string = 'Edit Gallery 1';
    Edit_my_gallery = new _.extend( options, { text: Edit_my_gallery_string } ) ); '.media-menu', Edit_my_gallery, _.extend( options, { add: true	 } ) );

    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 1 replies (of 1 total)
  • 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();'[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 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).

Viewing 1 replies (of 1 total)
  • The topic ‘Need to edit galleries from text editor’ is closed to new replies.