I have installed imagebrowser, patched fckeditor, and I get the Image Browser window up, but it only says:

Loading...

And my apachelog gets these error messages:

[Fri Oct 31 22:59:08 2008] [error] [client 127.0.0.1] File does not exist: /Volumes/xampp/xampp/xamppfiles/htdocs/modules, referer: http://localhost/vogol/?q=imagebrowser/view/browser&app=FCKEditor
[Fri Oct 31 22:59:08 2008] [error] [client 127.0.0.1] File does not exist: /Volumes/xampp/xampp/xamppfiles/htdocs/themes, referer: http://localhost/vogol/?q=imagebrowser/view/browser&app=FCKEditor
[Fri Oct 31 22:59:08 2008] [error] [client 127.0.0.1] File does not exist: /Volumes/xampp/xampp/xamppfiles/htdocs/sites, referer: http://localhost/vogol/?q=imagebrowser/view/browser&app=FCKEditor
[Fri Oct 31 22:59:08 2008] [error] [client 127.0.0.1] File does not exist: /Volumes/xampp/xampp/xamppfiles/htdocs/misc, referer: http://localhost/vogol/?q=imagebrowser/view/browser&app=FCKEditor
[Fri Oct 31 22:59:08 2008] [error] [client 127.0.0.1] File does not exist: /Volumes/xampp/xampp/xamppfiles/htdocs/misc, referer: http://localhost/vogol/?q=imagebrowser/view/browser&app=FCKEditor
[Fri Oct 31 22:59:08 2008] [error] [client 127.0.0.1] File does not exist: /Volumes/xampp/xampp/xamppfiles/htdocs/sites, referer: http://localhost/vogol/?q=imagebrowser/view/browser&app=FCKEditor

Comments

jdelaune’s picture

Ok sorry about the issues, do you have clean url's enabled? It could be an issues with CVS let me download the module from here and give it a go. I'll get back to you soon :)

jdelaune’s picture

Ok I can see where the issues lies.

How good are you with code? lines 137-145 contain links to files, i'm guessing you haven't installed drupal in the root directory or something? I will look into a better way of referencing the files.

  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css" />
  <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css" />
  <link type="text/css" rel="stylesheet" media="all" href="/themes/garland/style.css" />
  <link type="text/css" rel="stylesheet" media="all" href="/'.drupal_get_path('module', 'imagebrowser').'/imagebrowser.css" />
  <script type="text/javascript" src="/misc/jquery.js"></script>
  <script type="text/javascript" src="/misc/drupal.js"></script>
  <script type="text/javascript" src="/'.drupal_get_path('module', 'imagebrowser').'/imagebrowser.js"></script>

Change as needed for a quick fix :)

jdelaune’s picture

Assigned: Unassigned » jdelaune
Status: Active » Needs review
StatusFileSize
new2 KB

Hey try applying this patch to the original imagebrowser.module

Let me know if it works.

jdelaune’s picture

Do let me know if this fixed your issue. If it didn't I will look into it further :)

pkej’s picture

I haven't applied the patch yet ;) But a visual inspection of the patch looks promising. I will try to set up a test site with this tonight, when the kid has fallen asleep.

pkej’s picture

Title: No joy » base_path patch No Joy yet
StatusFileSize
new5.17 KB

I've patched ImageBrowser with #3 and it doesn't solve all the problems. I still get "loading", but now the windows seems to find more of its elements than before, the loading has moved to the middle of the window, instead of as a list item just under the "All|mine" drop down.

I checked out your javascript and it makes the same assumption. Of course, now I should have attahced a patch file, but unfortunately I don't know how to get the basepath. Well, I think I do...you could put the basepath as a) a hidden field b) as a base path variable in the head of the form you output and then use js to get that basepath.

There might be a Drupal js function to call as well, but I didn't find any in drupal.js.

Line 311:

        $row[] = '<a href="javascript:SelectFile(\'/imagebrowser/view/image/'.$nid.'/'.strtolower($size['label']).'\', \'\', \'\', \''.$node->title.'\');">Insert</a>';

to:

        $row[] = '<a href="javascript:SelectFile(\''.base_path().'/view/image/'.$nid.'/'.strtolower($size['label']).'\', \'\', \'\', \''.$node->title.'\');">Insert</a>';

Line 332:

          $row[] = '<a href="javascript:SelectFile(\'/imagebrowser/view/imagecache/'. $nid.'/'.$preset['presetname'].'\',\'\',\'\',\'\');">Insert</a>';

to

          $row[] = '<a href="javascript:SelectFile(\''.base_path().'/view/imagecache/'. $nid.'/'.$preset['presetname'].'\',\'\',\'\',\'\');">Insert</a>';

Those two previous blocks of code are very similar, I would have refactored them out into a function, and just sent the path elements which are different into it, especially if there might be more if/else clauses in the future (for asset module, for filefield module etc).

Finally you need to change:

Line 232:

    $output .= '<li><a href="/imagebrowser/load/imagedetails/'.$image->nid.'"><img src="/imagebrowser/view/image/'.$image->nid.'/thumbnail" alt="'.$image->title.'"/></a></li>';  }

Needs to be changed to:

  $preset_size = "thumbnail"; // Change to a load var preset in the future?
  
  $file = new stdClass();
  $file->fid =  db_result(db_query("SELECT fid FROM {image} WHERE nid = '%s' AND image_size='%s'", $image->nid, $preset_size));
  $file->filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = '%s' AND filename='%s'", $file->fid, $preset_size));
  
  $output .= '<li><a href="'.base_path().drupal_get_path('module', 'imagebrowser').'/load/imagedetails/'.$image->nid.'"><img src="'.base_path().$file->filepath.'" alt="'.$image->title.'"/></a></li>'; }

Line 266:

      $output2 = '<div class="image"><img src="/image/view/'.$nid.'/thumbnail" alt="Thumbnail" /></div>';

to:

      $preset_size = "thumbnail"; // Change to a load var preset in the future?
  
  	  $file = new stdClass();
  	  $file->fid =  db_result(db_query("SELECT fid FROM {image} WHERE nid = '%s' AND image_size='%s'", $image->nid, $preset_size));
 	  $file->filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = '%s' AND filename='%s'", $file->fid, $preset_size));

      
      $output2 = '<div class="image"><img src="'.base_path().$file->filepath.'" alt="Thumbnail" /></div>';

The above works with table name prefix and installed in a subdirectory, there are still bugs, when clicking on an image the javascript won't update the "Insert Image" fieldgroup. I think that's because I'm using "Clean URLs" and "Auto Nodetitle", so there has to be a call to a proper function to fix that.

I'll don't know if I can make a patch, I will try, but I'm saving this so it won't get lost ;)

pkej’s picture

Status: Needs review » Needs work
StatusFileSize
new5.22 KB

Another patch, I added drupal_get_path_alias it didn't break anything which wasn't broken already, but I don't know if it does the right thing either ;)

pkej’s picture

BTW, my patches are against a clean dev version, without any patches applied before. So the patch in #7 includes #6 and #3 in the same patch.

jdelaune’s picture

Cheers what I'll do is install a local copy outside the root directory for testing. I committed some new code last night which I don't think has been packaged yet, so I'll work from that and get back to you once everything is sorted.

Thanks for the patches!

pkej’s picture

BTW, I wouldn't touch the javascript, it seems I might be mistaken there, I read the:

$("#browse .browse").load('/imagebrowser/load/images/'+filter+'/'+sort+'?page='+parts[1], function() {
      prepareLinks(this);

And thought it needed the subdir I installed in infront, but now I notice that it is just using the module path, and I can't see how you find the rest of the path, thus I'm not sure where the paths are comming from, probably some of the PHP.

I should test on a webserver where I don't have a subdirectory, but all my development is done on xampp on Mac, so it is a bit of a hassle to upload unfinished stuff to a server ;)

Best regards,
Paul

pkej’s picture

The file upload works from the ImageBrowser. Now, will you create a NodeBrowser ;)

Hmm, wonder how much work that would be if I started with the image browser?

pkej’s picture

I think we need to add the $lang variable to the drupal_get_path_alias, but that needs an optional drop down in the ImageBrowser to sort images based on language of the node they belong to. That is needed for most of the sites I use, and epsecially the one where I want to add this functionality to.

The images will in most cases have the same files though, so the file look up I've added should be okay.

jdelaune’s picture

Not sure if we need drupal_get_path_alias(); and all the calls you made to the database. I worked on a version that works without Clean URLs and within a subdirectory. As for locale support I'll look into that a bit more.

Cheers

pkej’s picture

Tnx, as soon as I see a new package I'll download and test here.

jdelaune’s picture

new package is out let me know what happens. Never setup locale so I might need some guidance on what the issues are and what should happen :)

pkej’s picture

The 6.x-dev packaged worked pretty well.

I'll file separate issues for other problems, as they arise.

jdelaune’s picture

Status: Needs work » Fixed

Image nodes are 'Language neutral' so I don't see the need for a language drop-down. I fixed one issue with different locale settings. I'll commit it a bit later tonight. Like you said if you have any more issues open a new open new. Cheers.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.