Fix WP Gallery Remote plugin for Wordpress 2.7

Jed | January 28, 2009

Warning: This post assumes a lot of prior knowledge about Wordpress and the WP-Gallery-Remote plugin. I’m writing this post to help any others out there on the internets who also use this plugin and ran into the same problem I did.
wp+galleryI use the WP-Gallery-Remote plugin to show pictures on this blog. Unfortunately after I upgraded to Wordpress 2.7 it stopped working completely. It would still show pictures if I added the special markup to each post manually, but the handy popup editor would no longer insert the tag automatically into my post.

It turns out the problem and fix are very simple. The JavaScript that inserts the special tag into the page is broken because it relied on the structure of the Add New Post/Edit Post page which has changed in Wordpress 2.7.

The problem is with the index of the forms array on line 63 of wp-content/plugins/wp-gallery-remote/mce_plugin/wp-gallery_remote_mce_plugin.js:
insert_wp_gallery_remote_tag_AtCursor(window.opener.document.forms[0].content, tag);

Starting with Wordpress 2.7, the main post content form is no longer the first form on the page. Now in 2.7 the “Screen Options” dropdown on the top right of the page is the first form. This means that forms[0] no longer points to the post textarea.

So to fix the WP-Gallery-Remote plugin to work with Wordpress 2.7, just edit line 63 of wp-gallery_remote_mce_plugin.js and change that 0 to a 1. Or if you want to get more fancy, you can fix the plugin so it will keep working even if the Add New Post/Edit Post page changes in a later Wordpress release by changing line 63 to this:
insert_wp_gallery_remote_tag_AtCursor(window.opener.document.getElementById('content'), tag);

Presto, working Gallery2 editor in posts!

4 responses

This fix does not work for me in WP v2.7.1

B. Brunes

This fix does not work for me in WP v2.7.1 :-(

Brunes, which fix did you try? I'm running 2.7.1

Jed

Brunes, which fix did you try? I’m running 2.7.1 and the WP-Gallery-Remote works fine after applying the second fix. Keep in mind that you’ll always get array_search() errors when you first click the WP-GR tag but if you click Clear Album’s Image Cache the errors go away. I had this problem way before upgrading to WP 2.7.1 and I haven’t had time to investigate yet.

Hi there, the fix helped with the plugin to show

Jacq

Hi there, the fix helped with the plugin to show up and pull all the images from the galleries, but when I am ready to insert the images, the inert tag button does not work~

Any ideas?

Thank you in advance for all your help!

Oh, doh... I know what was the problem. I copied

Jacq

Oh, doh… I know what was the problem. I copied and pasted the fix directly but forgot to replace the single quote with code type… it works now! Thanks!

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>