Hi all,
apologies if I've put this in the wrong place, but I thought it might be useful for someone.

I've previously used TinyMCE along with the Gallery module, using the G2Image filter. When I switched to WYSIWYG it took me a while to make this work, but I think I've finally managed it.

This is what I did :

gallery/gallery_g2image/gallery_g2image_settings.inc:
in the function _gallery_g2image_settings_validate, change the switch instance for 'tinymce' to:

    case 'tinymce':
      $mode = t('TinyMCE');
      if (module_exists('tinymce')) {
        $path = drupal_get_path('module', 'tinymce');
      } else if (module_exists('wysiwyg')) { 
        $path = drupal_get_path('module', 'wysiwyg');
      }
      $path .= '/tinymce/jscripts/tiny_mce/plugins/g2image';
      break;

and change the function _gallery_g2image_path to:

function _gallery_g2image_path($path = NULL) {
  if (!isset($path)) {
    // Standalone G2Image folder
    $path = drupal_get_path('module', 'gallery_g2image') .'/g2image';
    if (!file_exists($path .'/config.php') && !file_check_directory($path)) {
      $path = NULL;
      // TinyMCE folder for G2Image plugin
      if (module_exists('tinymce')) {
        $path = drupal_get_path('module', 'tinymce');
        $path .= '/tinymce/jscripts/tiny_mce/plugins/g2image';
        if (!file_exists($path .'/config.php') && !file_check_directory($path)) {
          $path = NULL;
        }
      } else if (module_exists('wysiwyg')) {
      // WYSIWYG folder for G2Image plugin
        $path = drupal_get_path('module', 'wysiwyg');
        $path .= '/tinymce/jscripts/tiny_mce/plugins/g2image';
        if (!file_exists($path .'/config.php') && !file_check_directory($path)) {
          $path = NULL;
        }
      }
    }
  }

  // Store location of G2Image
  variable_set('gallery_g2image_path', isset($path) ? $path : FALSE);

  return $path;
}

This lets the g2image filter be configured in the gallery settings form correctly when adding it as a tinymce plugin.

I also needed to amend code in the WYSIWYG module - I'll submit this to them, but I've included it so there's a complete solution here.

wysiwyg/editors/tinymce.inc - added the following lines into the wysiwyg_tinymce_plugins function:

    'g2image' => array(
      'path' => $editor['library path'] .'/plugins/g2image',
      'buttons' => array('g2image' => t('g2image')),
      'internal' => TRUE,
      'load' => TRUE,
    ),

Comments

sun’s picture

Title: WYSIWYG, TinyMCE & G2Image filter integration » Add support for Wysiwyg API to G2Image

Better title.

Instead of hacking files in Wysiwyg module, g2image should implement hook_wysiwyg_plugin(). See #287025: IMCE_Wysiwyg API bridge module for a similar implementation.

profix898’s picture

Status: Active » Needs work

I have added iweb's code for now, but I will write a patch to support Wysiwyg API shortly (marking 'code needs work').

mike15’s picture

Found out about G2Image from gallery2 module and was wondering if the solution is being or planned to be implemented in the near future?

Thanks in advance.

helmo’s picture

StatusFileSize
new1.18 KB

I implemented a hook_wysiwyg_plugin() as suggested by sun.

This patch should obsolete the need for a code change in wysiwyg/editors/tinymce.inc

cayenne’s picture

What about those of us in Drupal 5 world? Any hope for us?

Ink_n_Image’s picture

Thanks so much for this!

It works fine in the editor, however under the gallery settings/G2Image tab it says G2Image is not installed. Is this the way it needs to be for now?

Cheers

Toddv’s picture

Still having trouble getting the g2image button to appear in wysiwyg/tinymce. Help appreciated

What I did:

I've been a longtime user of gallery, gallery module, and tinymce (now wysiwyg). On various sites I have a number of combinations of these currently. So I was ready for a bit of wrestling to get d6.12, gallery 2.3, gallery module, wysiwyg 2.0, tinymce, and g2Image to play nice with each other.

Starting from the point where everything worked EXCEPT g2image I added a directory structure within wysiwyg like this:
sites>all>modules>wysiwyg (what I added starts here) >tinymce/jscripts/tiny_mce/plugins/g2image/

I had previously put g2image where I would expect to have to put it - within the tinymce directory (..sites/all/libraries/tinymce/jscripts/tiny_mce/plugins/g2image/). But g2 image configuration in gallery module will not find it there.

The directories are empty except then I put the full g2image into the new "plugins" folder.

Now gallery module will configure g2image but still no button.

Using latest versions of d6.12, gallery 2.3, gallery module 6.x-1.- g2 image 3.03, wysiwyg 6.x-2.0 w/ tinymce 3x.

I uninstalled gallery and g2 image, wysiwyg/tinymce, deleted the db tables, and started again. I can get the button to show in the options within wysiwyg configuration but still no g2 button appears on node/edit fields.

I also edited function wysiwyg_tinymce_plugins($editor)
'G2Image' => array(
'path' => $editor['library path'] .'/plugins/G2Image',
'buttons' => array('G2Image' => t('G2Image')),
'internal' => TRUE,
'load' => TRUE,
),

Which is what got the button to appear in the config list...
Thanks for any advice

Toddv’s picture

Hot damn! Got it working.
1. The easiest way for me to do it was install all these d6.12, gallery 2.3, gallery module 6.x-1.- g2 image 3.03, wysiwyg 6.x-2.0 w/ tinymce 3x.(current version as of June 28, 2009)

2. I put g2image in two different directories:
a. proper place: ..sites/all/libraries/tinymce/jscripts/tiny_mce/plugins/g2image/
b. But g2 config for g2image (in the admin>gallery>setup pane) wanted a copy here: ../sites/all/modules/wysiwyg/tinymce/jscripts/tiny_mce/plugins/g2image/

When I saved the configuration settings from gallery settings g2 image it wrote the config file in ../sites/all/modules/wysiwyg/tinymce/jscripts/tiny_mce/plugins/g2image/. But wysiwyg looks for the settings in ..sites/all/libraries/tinymce/jscripts/tiny_mce/plugins/g2image/. So I just copied from one to the other.

Running the patch in #4 is what makes it all work.

josh68-1’s picture

Hello Toddv,

I've already spent hours trying to make it work.... with no success.
I've followed your steps but didn't apply the patch yet, I can see the G2Image check box in TinyMCE, but once I check it TinyMCE stops working for editing (text mode rather than wysiwyg mode).

Could you detail the patching step?
I'm under Xp with wamp. I managed to get the patch utility from gnuwin32; in what folder do I run "patch

Thank you for your help.

Josh

helmo’s picture

Please have a look at http://drupal.org/patch/apply

depending on the value of the -p option, you could e.g. with -p3 be in the sites/all/modules/gallery/gallery_g2image/ directory.

iweb’s picture

StatusFileSize
new1.06 KB
new4.18 KB

I've been looking at this recently with regards to setting up multi-site drupal/gallery2 installs and had to revisit this.

The problem is that the wysiwyg module now expects tinymce to be installed in libraries/tinymce rather than the original modules/wysiwyg/tinymce, so when the gallery module looks for the g2image plugin it can't find it.

I've attached a patch which seems to resolve the problem with the following conditions:

  • If the libraries module (http://drupal.org/project/libraries) is installed, it should just work as is,
  • If the libraries module isn't installed, the tinymce library must be installed under the same branch as the wysiwyg module i.e. if wywiwyg is in [root]/sites/all/modules/wysiwyg then tinymce must be under [root]/sites/all/libraries/tinymce

As far as multi-site setups go, because the config.php file in the g2image plugins directory under tinymce is modified to reflect the location of the site-specific gallery, tinymce must be installed under the site-specific libraries folder. The gallery & wysiwyg modules themselves can either sit in sites/all/modules or site specific modules folders.

I'm going to try and put something in the handbook for how I've got multi-site drupal/galleries configured and working for me.

My patch is the gallery_g2image_settings patch which needs to be applied to gallery_g2image_settings.inc whilst the gallery_g2image.module.patch is the one mentioned in post #4 above.

MjrNuT’s picture

I have recently configured my single site this way. wysiwyg w/ tinymce. tinymce in libraries like you've described in your 2nd bullet.

My gallery is embedded (v2.3) so far w/o issue. URL rewrite is working properly. However, I cannot seem to get teh g2image to show as "enabled". Are these patches specific to resolve this? Forgive my lack of knowledge about this if it's staring me in the face.

Moreover, I presume this g2image is preventing me from embedding a photo from the gallery to a blog or page?

My sample URL to a single photo is:

http://www.mysite.com/gallery/v/Myalbum/subalbum/DSCF0372.jpg.html

I've read the description of the syntax use of: [G2: item_id n= number type= type size= number class= name frame= name album_frame= name item_frame= name ]

But I don't see where to obtain the necessary info for each field.

I apologize if this should not have been posted here and look for any assistance/direction.

Thanks

helmo’s picture

If all is well you should have a G2 icon in your tinymce toolbar, which allows you to lookup an image in a pop-up window.

After hitting the insert button on this pop-up a tag like "[G2:2637]" is added, and is sufficient in my setup to display a thumbnail.
The other parameters are optional, of which size is probably the most commonly used.

patrickkhong’s picture

will this be implemented in the next wysiwyg version?

MjrNuT’s picture

I did not have to perform any patches.

I followed this to implement a successful g2image installation. http://drupal.org/node/300305

The OP, imo, lacks some details.

koppie’s picture

This issue is older than my kid. I'm posting here so I can keep an eye on it. I don't want to hack code myself; I'm hoping the devs will step back in and make it work again.

koppie’s picture

I'm sorry, I should have read #300305: Gallery2 G2Image installation issues more closely! Turns out all I needed to do was add g2image to /www/sites/all/libraries/tinymce/jscripts/tiny_mce/plugins. Seems like that's not the "right" place, which is why people are editing the plugin, but it was a simple fix and I managed to avoid hacking code.

If we could add this to the installation instructions, I think that would solve the problem right there.

milplus’s picture

StatusFileSize
new6.45 KB
new6.45 KB

hi todd

Could you detail the patching step?

I di not know I followed your instruction with no luck

Gallery2 is integrated but I need to understand how dod you make it to get it working.

Please give me an help.

Again when I open the G2 Button I get:

Fatal Gallery2 Error: Cannot activate the Gallery2 Embedded functions.
For WordPress users, Validate WPG2 in the Options Admin panel.
For other platforms, please verify your Gallery2 path in config.php.

I'm sure it is not a matter of config.php.
I've attached the config.php A & B -

as mentioned by you I see they are both the same so no need to swap them in.

please advise why your sentence.

thanks

milplus’s picture

Todv
ciao can you answer to my below post please

http://drupal.org/node/350100#comment-5524702
thanks

milplus’s picture

Title: Add support for Wysiwyg API to G2Image » Add support for Wysiwyg API to G2Image chooser steffensen

dear sirs

the key question is

this bloody config.php file is going to be which one?

Steffensen the developer of this tool supposently does not describe all it is needed :

first where g2image goes installed and in how many places

1) in .../sites/all/libraries/tinymce/jscripts/tiny_mce/plugins/g2image config1.php
2) in .../sites/all/modules/wysiwyg/tinymce/jscripts/tiny_mce/plugins/g2image config2.php

in both or in 1) or in 2).

the config files you have are minimum 2 one in 1) and one in 2). these files are different despite with same name.

config1 is supposently formed by the setup in drupal of g2image

config2.php no .get not compiled and updated by drupal.

I have addedd g2image button in my wysiwyg configuration ( I have installed tinyMCE too).

any time I click on G2 IMAGE BUTTON I have the below message:
Fatal Gallery2 Error: Cannot activate the Gallery2 Embedded functions.
For WordPress users, Validate WPG2 in the Options Admin panel.
For other platforms, please verify your Gallery2 path in config.php.

WHICH config.php file do we mean. ? this is the question.

I would suppose the one not compiled by Drupal G2 - however after checking and setting this properly as fer steffensen instruction on webpage nothing change error remain same.

Hope someone can help me.

thanks

milplus’s picture

Guys I need to create an hook up() to use G2image chooser within Product editor in ubercart.

is there anyone can help me on that ?

I've tried to filefield_source but this module makes Drupal getting stuck at any node editing . it would be good apparently but wont work on my actual configuration.

hope I can receive a good feedback