In imagefield_gallery_lightbox2.module function theme_imagefield_gallery_lightbox2 there is bad code for URL creation.

This part

        if ($preview == '_original') {
          $imagecache_path = base_path() . $file['filepath'];
        }
        else {
          $imagecache_path = base_path() . file_directory_path() .'/imagecache/'. $preview .'/'. $file['filepath'];
        }

should be

        if ($preview == '_original') {
          $imagecache_path = file_create_url($file['filepath']);
        }
        else {
          $imagecache_path = imagecache_create_url($preview,$file['filepath']);
        }

There is no reason for building our own URLs when there are standard functions for this.

And I hope convergence with lightbox2 module goes on so things like this don't happen. This code is correctly working in lightbox2 module.

Comments

eclipsegc’s picture

Sorry, it's hard to become an expert in all the details of every module one might need to understand before setting out to build their own module on the first pass. I'll make sure this makes it into the 2.x alpha.

Thanks!

Eclipse

eclipsegc’s picture

So, this code you've submitted is imagecache 2.0 only. It's important to note that right now I'm still supporting imagecache 1 and imagefield 1 ALONG WITH the 2.x version of both those modules. Got some code that will handle both of them?

Eclipse

Farreres’s picture

No idea. There is the module_exists function, perhaps there is some module_version equivalente so you can ask for imagecache 2.0 or greater and then use this code. Otherwise use old code. Just an idea.

Farreres’s picture

Hey, I just saw this new module:

http://drupal.org/project/modver

It will help developers know the module version installed. This way the problem of knowing if imagecache 1 or 2 is installed could be solved.

dobeerman’s picture

Version: 5.x-1.4 » 5.x-2.0-alpha1

If use original code:
Link to thrumbnail http://mysite.ru/files/imagecache//files/gallery/1/1659.jpg

If use patch:
Link to thrumbnail http://mysite.ru/files/imagecache/%252Fgallery/1/1659.jpg

why $preview is empty?

PS. /1/ = uid

eclipsegc’s picture

Beerman,

If you've made use of the code in this issue, it is specific to imagecache 2.x ONLY! If you're using imagecache 1.x it will NOT work. Which is exactly why this code will not be making it into the next release cycle.

Eclipse

dobeerman’s picture

ImageCache 5.x-2.1

eclipsegc’s picture

Beerman,

Well, as I only did enough research to see that this code wouldn't work with 1.x I never tested it with 2.x, so this is NOT a supported alteration of the module. Why are you trying to alter it at all? The existing code works just fine.

Eclipse

eclipsegc’s picture

Assigned: Unassigned » eclipsegc
Category: bug » feature
Priority: Critical » Minor
Status: Active » Closed (won't fix)