Media-Tag duplicate submenus fix
-
Installing File-Gallery and Media-Tags produces two Media->Media Tags submenus, which is confusing. As File-Gallery claims compatibility with the other guys, I added the following code to the file-gallery.php [1.7RC2]:
~ li 762
/** * Adds media tags submenu */ function file_gallery_media_submenu() { add_submenu_page('upload.php', __("Media tags", "file-gallery"), __("Media tags", "file-gallery"), 'upload_files', 'edit-tags.php?taxonomy=' . FILE_GALLERY_MEDIA_TAG_NAME); } // ** [alx359] Media-Tags plugin compatibility: avoid of duplicated media-tags menu if ( ! function_exists ( 'is_plugin_active' ) ) require_once ( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( ! is_plugin_active("media-tags/media_tags.php")) add_action('admin_menu', 'file_gallery_media_submenu'); // **Hope something similar makes to the final 1.7 version
-
In that line of thoughts, when one disables the Media-Tag plugin all the existing Media tags dissapear (which were added via Media-Tag). Similarly, if enabling Media-Tag after adding tags via File-Gallery they dissapear too. Would be nice these dependencies to be exposed via admin cfg params.
The rationale is that using Media-Tag gives the bulk tag mgmt facility that File-Gallery is currently lacking, but this could change in the future versions.
Another one giving some issues with Media-Tag compatibility. During Edit Post -> Upload/Insert -> Media Library. When the list is populated there’s an overlapping of the File-Gallery and Media-Tags checkboxes, which makes difficult to check the Media-Tags ones which should take precedence. The offending code is in file-gallery-attach.js ~ li 22:
/*** [alx359] // adds a checkbox to each attachment not already attached to current post jQuery('.media-item').each(function() { if( ! jQuery(this).hasClass("child-of-" + post_id) ) jQuery(this).prepend('<input type="checkbox" class="attach_me" value="' + jQuery(this).attr('id').split('-').pop() + '" />'); }); ***/Unfortunately, apart of commenting I can’t offer a better solution. Somehow the $is_plugin_active(‘media_tags.php’) needs to make it to JS.
[EDIT] Unfortunately, I’m wrong. Just commenting does not do the job. The “Attach All Checked to Current Post” button [by File-Gallery] expects its own checkboxes. Not sure yet what to do.
*
A small cosmetic one is in the Media Library (wp-admin/upload.php). There’s a duplicating of the Media Tags checkbox from both plugins, but seems to work fine with either of them.
(WP edit timeout?)
Re: “Attach All Checked to Current Post” fix.
Additionally to the commented snippet above, need to change the following:file-gallery-attach.js ~ li 44:
/*** [alx359] Media-Tags plugin integration. Change line below ****/ //ids : jQuery.map(jQuery('.attach_me:checked'),function(i){return jQuery(i).val();}).join(","), ids : jQuery.map(jQuery('.bulk-media-tag-item:checked'),function(i){return jQuery(i).val();}).join(","),i’ve added a couple of lines of code to address the checkboxes issue, will try to update the development version tonight
Great, tell us when available and will test.
ok, v1.7-RC3 is in the trunk.
you can download it from here: http://downloads.wordpress.org/plugin/file-gallery.zip
thank you so much for testing it! π
Hi Bruno,
Haven’t had the chance to test much, but until now everything seems working fine. The only that bothers me a bit is that in the Media Library thickbox (the Upload/Insert link in page/post edits) now there are 2 columns of checkboxes which looks IMO cluttered and confusing. Let me suggest we try to reuse any checkboxes already there (say media-Tags) before creating new ones.
I have added the following piece to file-gallery-attach.js ~23
// adds a checkbox to each attachment not already attached to current post jQuery('.media-item').each(function() { //// [alx359] a checkbox for this attachment already exists? lets enhance it! var cbh = jQuery(this).find(":checkbox"); //short-hand if (cbh.length) { cbh.addClass('attach_me'); if( jQuery(this).hasClass("child-of-" + post_id) ) { cbh.addClass('empty'); cbh.prop("checked", true); cbh.prop("disabled", true); } } //// else { // no checkbox found, create a new one! if( ! jQuery(this).hasClass("child-of-" + post_id) ) jQuery(this).prepend('<input type="checkbox" class="attach_me" value="' + jQuery(this).attr('id').split('-').pop() + '" />'); else jQuery(this).prepend('<input type="checkbox" class="attach_me empty" checked="checked" disabled="disabled" />'); } //// });Additionally, when Media-Tags is installed, it has given us the check-all feature for free π
Cheers,
AlexOkay, a side-effect of the proposed change: ‘attach_me’ styling is messing up in the Media-Tags layout.
To stick to this idea of adaptiveness, we need to move styling to another class.
in file-gallery.css ~740:
make attach_me dummy and use attach_me.css instead for styling purposes.attach_me {} /* do not style */ .attach_me.css { /*position: absolute; right: 0; top: 1em;*/ float: right; margin: 11px 6px 0 0; }Same above code still applies, just adding the new ‘css’ class to our checkboxes only:
//// else { // no checkbox found, create a new one! if( ! jQuery(this).hasClass("child-of-" + post_id) ) jQuery(this).prepend('<input type="checkbox" class="attach_me css" value="' + jQuery(this).attr('id').split('-').pop() + '" />'); else jQuery(this).prepend('<input type="checkbox" class="attach_me css empty" checked="checked" disabled="disabled" />'); } ////Okay, another (and hopefully last) side-effect of the reusing of existing checkboxes idea. When adding class ‘attach_me’, one may also need to ensure the checkbox is properly init. I stumped into this after finding jQuery(‘.attach_me:checked’) returns an array of ‘on’ values even for unchecked elements (the checked ones contain value=id as it should) .
So the (final) patched code:
// adds a checkbox to each attachment not already attached to current post jQuery('.media-item').each(function() { //// [alx359] a checkbox for this attachment already exists? lets enhance it! var cbh = jQuery(this).find(":checkbox"); //short-hand if (cbh.length) { cbh.addClass('attach_me'); cbh.prop("checked", false); // proper init state cbh.prop("disabled", false); // if( jQuery(this).hasClass("child-of-" + post_id) ) { cbh.addClass('empty'); cbh.prop("checked", true); cbh.prop("disabled", true); } } //// else { // no checkbox found, create a new one! if( ! jQuery(this).hasClass("child-of-" + post_id) ) jQuery(this).prepend('<input type="checkbox" class="attach_me css" value="' + jQuery(this).attr('id').split('-').pop() + '" />'); else jQuery(this).prepend('<input type="checkbox" class="attach_me css empty" checked="checked" disabled="disabled" />'); } //// });ok, added similar functionality, thanks π
fixed in v1.7-RC7 which should be out tomorrow
added in v1.7-RC7, you can download it from here: http://wordpress.org/extend/plugins/file-gallery/download/
please let me know if everything works alright, thanks! π
Beautiful.
I stumbled upon the Media-Tags plugin and had issues with everything that was raised here. I’ve downloaded and installed v1.7-RC7 and it seems to be working fine.
Do you suggest I go ahead and upload v1.7-RC11 since it is available now?
Thanks so much for this thread & work!
Yes, I think you can safely install RC-11, there should be subtle overall improvements π
The topic ‘Media-Tag duplicate submenus fix’ is closed to new replies.