in Technology

WPG2 Plugin, TinyMCE Javascript problem

I have WordPress 2, Gallery 2, and the WPG2 plugin to insert Gallery photos in WordPress.

And I am bugged by a problem with this setup for a long time!

window.opener.document.forms[g2ic_form] has no properties
insertImage (form#something.JPG.hidden_form g2image.php)
onclick(click clientX=0, clientY=0)
insertAtCursor(window.opener.document.forms[g2ic_form].elements[g2ic_field],im...
Happens in functions.js (line 133)

The only link that comes up when I search for “window.opener.document.forms[g2ic_form] has no properties” on Google is a forum post on WPG2 site. The post does talk about the same problem, gives a few alternates to solve the problem, but no final solution.

I figured out the pattern in the problem. Here’s what happens:

  • You go to write a new post. Write something, and click on the WPG2 icon in the visual editor to bring up the Gallery 2 Image Chooser.
  • If you select an image from the root of your gallery, it will insert well into the post.
  • If you navigate into any albums / sub-albums, and then select an image, it will not insert into the post, and you will get the annoying JavaScript error. Non techies may not even realize there is a JavaScript error, and will just get confused why the image does not insert.
  • If you close the Image Chooser window, come back to the post, and click on the WPG2 icon again, it will open the Image Chooser in the place you left it – the same album / sub-album that you were last on.
  • If you now click on an image, it will insert in the post without errors.
  • My theory is that the Image Chooser is not able to (somehow) retain the window.opener over page refreshes. When you navigate inside albums, the Image Chooser page is refreshed. At this time, it just forgets who opened it. And throws out the error. When you reopen it, it does know which window opened it, and can insert the image well.

Hope this helps some worried souls!

Write a Comment

Comment

  1. There is no real fix I’ve found yet. As I described in the post, navigate to the gallery you want to insert from. Close the window, click on Gallery icon in the editor to open the window again, and then insert the image. That made it work for me consistently.

    HTH.

  • Related Content by Tag