I've been spending some time recoding the Fast Gallery module, all starting with trying to resolve this issue and this issue. Along the way, I started fixing this and that, and then got a bit carried away. So here is the result, including fully-working sorting options, customizable title and path alias, customizable caption format, caption labels, and more. Attached screenshots.

Documentation included. Please take a look at the README and the help section.

IMPORTANT
Please fully DISABLE and UNINSTALL any previous versions of Fast Gallery. I did not write any update code because this is not an official release. This version uses a slightly different database schema and a few different variables. Please make backup copies of any important files, and try out the module first on a test site if you are able to. I consider this code to be in alpha stage. It's functional but not fully tested.

If you need to edit EXIF data in JPG files, I have been using and highly recommend EXIFManager (http://phgiraud.free.fr/exifmanager).

Enjoy!

-nick

ADDITIONS
---------

  • Support for folders within folders with no images
  • Custom caption display; up to 3 fields. Choose content of each field in a
    dropdown on General settings page.
  • Support for Clean URLs.
  • Dropdown selection choice for Lightbox slideshows.
  • Support for setting custom title and custom path alias.
  • Updated CSS sheet for different look and adjusted layout.
  • Support for case-insensitive file type extensions.
  • Support for displaying images with no EXIF data (i.e. all non-JPG files).
  • Also now includes JPG files with blank EXIF data.
  • Sorting for when hierarchy is disabled.
  • Graceful error handling (error message) for unsupported filetypes for internal cache (just BMP right now).
  • Error handling for non-existent directories in URL path.
  • Option for selecting no Javascript framework. Links go directly to
    images. Thickbox and Lightbox will now only display as options when they
    are installed.
  • Spaces in URL path get changed to underscores.
  • Corrected code for generating internal cache thumbnails. Now handles
    square images without distorting them.
  • File fast_gallery.admin.inc to separate code for settings pages
  • Help page, more help text in settings pages, README.txt, and this
    CHANGES.txt file.
  • Setting number of images per row. Required to fix layout of overlapping
    images with captions.
  • Rewrites of functions, code blocks
  • Code commenting throughout.
  • .pot file for translations.

ISSUES ADDRESSED
--------------------

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ncy’s picture

here's a pic of Lightbox in action. there were some posts about Lightbox not working right, but it works great for me. slideshows work too! :) (p.s. i did have to edit the lightbox.css file a bit to position the buttons correctly).

lomz’s picture

Thanks, this is by far the best gallery module to Drupal

tompte’s picture

Category: task » support
FileSize
5.44 KB
14.28 KB

Hello

I've try this version on one web site and it work without problems, great job !
On a second web site I have some problemes:
after configuring the module I clic on the link to show the galleries and I have this messages: see message.png

It look like the temporary tables are not created.
I've check the rights on mysql for this database and all the right are good (see mysql.png)

What can I do to find where is the problem ?
Drupal 6.4
MySQL: 5.0.32

tompte’s picture

FileSize
33.03 KB

Hi

I've found the problem:
In fast_gallery.class.php when you create a temporary table it's without the prefix (see in http://api.drupal.org/api/function/db_query_temporary/6 ).
then when you want to read this tables you must not put {} around the name of the table.
voilà

A second problem now:
My drupal is in a subfolder: drupal
when I clic on Fast galleries on my menu I have the first level of my galleries (http://xxx.xxx/drupal/fast_gallery) OK
If I clic on this first image it send me to http://xxx.xxx/drupal/drupal<?b>/fast_gallery/events and so on for each level!!!

OK I've found a solution for the second the problem, see the attached file for a version with a correction of the tow problems

Best regards
Philippe

ar-jan’s picture

Cool this works! However, when I click the thumbnail for a folder, it links to the adress like this:
http://mysite.com/ttp%3A/%252Fmysite.com/galleries/my-first-album
When I delete the incorrect part that has been added after the domain ("ttp%3A/%252F"), the gallery works, lightbox also works.

Philippe, thanks, your patched version in #4 solves my url problem too.

This now works on both my local testserver and the live server, very cool! This will be a very effective way of managing albums.

ncy’s picture

FileSize
33.06 KB

good finds Philippe! the base_path also needs to be fixed for the random image block code.

thanx for finding the SQL brackets problem, too. i learn something new everyday :) temporary tables are created for when Hierarchy is turned off, too. fixing that code now as well.

attaching version 3 of alternative version!

tompte’s picture

Happy that's help !!!
Thanks for your module is really usefull

Kiphaas7’s picture

Hi there,

I just tried this alt_v3 version, and it worked a lot better for me, but with hierarchy enabled, it shows no list of directories... Flat view works without a problem, but I eventually want to move this from a local test server to a live site, which has a lot of pictures in a lot of subfolders.

What it does show is an empty page, with only inside the div #fast_gallery are few div's with .clear followed by a br, and the pager, containing the exact same amount of pages as it would with just a flat view.

- Tried imagecache and internal one
- Tried adding pictures in the "root" gallery folder, didn't change anything
- the map name contains spaces, numbers and capitals, allthough I tried removing the spaces, numbers and capitals, and that didn't change anything.
- Friendly urls are on, turning them off didn't change anything..

So, again troubles with hierarchy... :(

ar-jan’s picture

Hm, I haven't tried the difference with this version, but what happens if you set the "sort by" to "name" for all sort options in Advanced?

ncy’s picture

hrmm, that is strange that it would have the same number of pages as in flat view (unless it's a coincidence that the numbers match up? the code should be doing 2 completely different things for flat view and hierarchy.)

here's some quick brainstorming:

1. glob() is used to explore the directories, but it isn't available in some systems. is it possible for you to upload it to the live site in a test location? maybe it will work there.

2. did you have any previous versions of Fast Gallery installed? make sure in go to Modules, disable it, save. then click on the Uninstall tab, check off Fast Gallery, and Uninstall. if i recall correctly, the uninstaller code for the 2.3 Fast Gallery misses a few variables, but i think the most important thing is that the database schema is updated.

3. try doing Clear DB and Rescan? refresh the browser page?

4. try with 1 or 2 folders first, and slowly add to it. maybe there's just one folder or image that it's choking on? unfortunately i haven't tried any large scale galleries yet. how many images are you working with?

5. any special characters like umlaut in any image or folder names? unfortunately, those aren't handled properly right now.

6. do you have more info about your setup? particularly, what is your folder hierarchy structure and where is each image located.

7. can you take a peek into your database and see if the fast_gallery and fast_gallery_exif tables look like they have good data in them?

any information helping me to duplicate the problem on my setup would be great.

that's all i can think about right now. hope we can get to the root of this problem. post back if you find out anything new. i'll try to help as best i can.

thx
-nick

Kiphaas7’s picture

Wow, fast reply :).

I'm using a xampplite install on a windows machine, and the live site is also on a windows machine, allthough it probably doesn't use xampp :).

1) is there a way to test/check for this? I have complete control over my local install...

2) Yes, but I disabled them and uninstalled them.

3) I always do that after changing settings. Clear DB, rescan and CTRL F5.

4) There is atm only 1 (sub)folder, containing 30 pictures, all in the format of DSC00001.JPG. Next to that subfolder, there are some testpics in the root folder. Those were added later, after I discovered that hierarchy didn't work for me.

5) No, and that won't be an issue for me. :)

6) I have my images located in the drupal root folder. Clarification: "path to gallery = foto/" for me. Inside that foto gallery, there are some loose images, and 1 folder, all lowercase, nothing special. Inside that folder are 30-ish images in the format of DSC00001.JPG.

7) Both those tables exist, and there is data in them. Data looks good to me. The only thing that looked strange to me, is that in the path contains both slashes and backslashes ( example: foto/subfolder\DSC00001.JPG ). Also, the parent field is empty for all my entries. Could the windows backslashes be it?

EDIT:

Skimming through the readme, I stumbled upon this:
* Filenames are treated with no regard to case, so don't give files the
same name.

Does that mean every filename needs to be unique, regardless of where they are? That would possibly be a big turnoff for me, as most files are straight from the camera, and don't have fancy filenames. So there could be dupes in the live site.

At the moment, the live site uses weatimages as gallery. Obviously this is not integrated in drupal, so I was looking for a good replacement of that one. This module has for me the most potential, so kudos for developing a straightforward, do-what-needs-to-be-done module! :)

ncy’s picture

FileSize
33.21 KB

ok, yea, i didnt think glob() would be the problem as most systems support it, and it was seeing all the files in the flat view. i think the database definitely is the telling story here. backslashes ("thanx Microsoft") are def a bad thing to have in the path. i'm guessing something with xampplite on Windows is messing with the path.

here's a version that replaces all backslashes with forward slashes before writing to the database. lemme know if that works better.

also updated the readme to clarify that filenames can be the same, as long as they're in different folders. files are identified by pathname, so the important thing is that 2 files have different paths if they are to have the same name. folders, on the other hand, are identified by its name alone, and its location is determined by the name of the parent folder (no path information). so folders can't ever have the same name regardless of where you are in the hierarchy.

cheers,

-nick :)

Kiphaas7’s picture

Well, that fixed it only for a little bit. I uninstalled the module, flushed the caches, reinstalled v4. Still no bueno with hierarchy.

The only change is that there is no longer a pager in the sourcecode of the generated page. The page still consists of clearing div's and an (now empty) pager div.

In the database the backward slashes are indeed turned into forward slashes, BUT, the "parent" field is still empty for all images. What should be in the parent field anyway, the subfolder name?

EDIT: also, small fix suggestion: you use <br>. Most drupal themes are xhtml, so it should be <br />. If there really is a need for xhtml, is a totally different discussion, but the point is that we're stuck with xhtml, might as well conform with it :). With that said, is there really a need for a clearing div AND a br?

ncy’s picture

whoops, my bad. i didn't realize that ALL of your parent entries were blank. that can also be attributed to a backslash problem. the parent is supposed to be the parent folder of that image/folder.

i'm renaming this zip as alpha-1.0, so i dont keep numbering up to v100 or something like that. when rapsli gets back from his vacation, maybe he can get this committed to CVS.

i changed the 2 places i use <br> to <br />. i'm not sure what to substitute the clearing div with. i'm not a CSS guru, and it's the only thing that i could get working right (to clear everything and go to next line). it's used to go to the next row. i inserted the <br /> just to give it some more space between rows.

-nick

Kiphaas7’s picture

And it works now. :) Many thanks!

@br:
In your case you could give .single-image some extra bottom-padding.

ncy’s picture

cool beans, glad to hear it's working now :).

yea, i guess a "margin-bottom: 1em" has the same effect as adding a <br>. i think without the clearing div the padding/margin wasn't working. me thinks somewhere in my fiddling i left it as a <br> instead of changing it back to CSS :P. is it a bad thing to have an empty div with just the clear in it? that's the thing i found i couldn't find a work around for.

Kiphaas7’s picture

Short story: It's the most stable work around. There are more elegant solutions, but enough time to worry about that later. :)

So, I moved the module to the live site, but guess what, more problems! :) Now the pager stopped working, it shows exactly the amount of pictures it should on 1 page, but no pager to different pages... And there are more pictures, of that I'm sure :P.

Seriously though, somehow magically the pager stopped functioning...

As a feature request: Could you make the folder list an item list?
$output = theme_item_list($tmp, NULL, 'ul', NULL) . $img_output;
instead of:
$output = implode(' | ', $tmp) . $img_output;

Another feature request: breadcrumbs while navigating through subfolders. Would be cool. :)

ncy’s picture

hrmm, lemme think on this a bit ...

when i had pager problems, it was because the sql_count query was getting screwed up in the pager_query() call, and it did exactly that, show only 1 page of pictures. but assuming that the database only stored forward-slash path data, the explode('/', ...) calls should be working correctly ... can you double-check the database on the live site and tell me what's there (any more backslashes?).

the theme thing makes sense. i'll def do that in the next update. it'd definitely make it easier to theme the look of text-link folders.

breadcrumbs aren't there? i do construct a breadcrumb and set it using drupal_set_breadcrumb() ... are you remembering to print out $breadcrumb in your theme? that's the only way to navigate around albums through different levels.

pimentoski’s picture

good work, but i have one problem, the special characters from the Portuguese language like "ç or à or ó" does not appear but if i go to mysql and do the update, then it works fine.

Kiphaas7’s picture

Woops, yup, breadcrumbs are out of my (custom) theme. I added it in the module for myself, since I don't need the breadcrumbs sitewide. :)

I'll also look into the pager stuff.... So far the tables look allright, all the fields have entries, and no backslashes, but I'll examine them more thorough.

Kiphaas7’s picture

I found a (dirty) solution for the pager problem:

// We need to specify a count query for pager_query()
//'.($result->num_rows + $result2->num_rows - $extra_count). '
$sql_count = 'SELECT COUNT(*) FROM fast_gallery_all_images';

This works for me....

ncy’s picture

i wonder why the pager_query is choking on your gallery :/

the problem with

$sql_count = 'SELECT COUNT(*) FROM fast_gallery_all_images';

is it ignores the number of folders, which is that i was complaining about in this post. :P

also, because the images are selected by folder, the images that are supposed to only represent folder thumbnails be counted are images in a folder, when they shouldn't be counted -- so you might end up with more pages than you expect, or a blank page at the end. that was the adjustment of subtracting "extra_count". these "extra" thumbnail records are necessary in the database to workaround this problem.

your code change is actually equivalent (or should be equivalent) to:

$sql_count = 'SELECT '.$result->num_rows;

does that do the same thing for you? did you pinpoint the problem down to that SQL count line of code?

Kiphaas7’s picture

I used print_r($sql_count), and that returned 0 for me while in a gallery which should have multiple pages. "extra_count" also returned zero, so I knew something went wrong with the counting of the rows. I just didn't know what :). After talking about it with my fellow siteadmin, who knows more about sql commands, but less of drupal, he suggested this and it worked. I realized that it didn't exactly do what you wanted it to do.

I'll try your code in a few hours and report back.

Kiphaas7’s picture

After changing it to your code
$sql_count = 'SELECT '.$result->num_rows;

it gives me the following error:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT

And no pager. :)

ncy’s picture

alrighty, let's try this mess of a SQL call instead :D

    $sql_count = 'SELECT SUM(count) FROM '.
      '(SELECT COUNT(*) AS count FROM fast_gallery_all_images UNION ' .
      'SELECT COUNT(*) AS count FROM fast_gallery_all_folders UNION ' .
      'SELECT -'.$extra_count.' AS count) AS tbl';

i'm guessing your server doesn't like the num_rows property ... either that or it doesn't like 'SELECT x' calls, where x is some arbitrary number

ncy’s picture

i'll try to look into special characters when i get back from traveling. i'm going to be out for about 1-2 weeks.

Kiphaas7’s picture

Yup, that works. Thanks :)

lomz’s picture

When will the alternative version become the official?
It is already better.

ncy’s picture

rapsli (Raphael Schär) is the original author and maintainer of this project. he made a post about 2 weeks ago that he was going on vacation for a few weeks, so probably soon.

i'm posting an alpha-1.1 version with the said changes above.

cheers,

-nick

jan.n’s picture

FileSize
27.66 KB

ncy: Thank you for your work!

The German characters äöü are not recognized in this version, the remainder of the text is cut off (also in lightbox), cf. attached picture.
The caption should read "Ganz schön eng hier"...

Regards
jan

Kiphaas7’s picture

When just rescanning the gallery, my images got added again to the db. This is another consequence of the backslash problem, and it's fixed by doing this:

        // Only make database changes if there's no previous record found
        $value_slash = str_replace("\\", "/", $value);
        $sql = "SELECT gid FROM {fast_gallery} WHERE path = '%s'";
        $result = db_query($sql, $value_slash);

:)

Thurgi’s picture

I tried to install the new version but everytime i try to open the galerie it spams me with messages like:

user warning: Unknown column 'filetype' in 'field list' query: CREATE TEMPORARY TABLE fast_gallery_images_noexif Engine=HEAP SELECT path, folder, gid, filetype FROM fast_gallery WHERE folder='galerie' AND filetype <> 'jpg' AND filetype <> 'jpeg' ORDER by path asc

ncy’s picture

jan, i'll take a look at special chars once i get back from my trip. i'm abroad right now.

Kiphaas7, thanx for the find. glad that you're helping debug and test!

Thurgi, if it cannot find the column 'filetype', it most likely means you did not uninstall the old version of Fast Gallery before installing the new one. make sure you disable it first on the Modules page, and then click on the Uninstall tab, and uninstall it. the database schema is different, so you have to completely uninstall the old version first.

-nick

rapsli’s picture

Was on vacation ... boa... lots happened here. I'll get my head around. I got no problems replacing the current version with this one... give me a couple days.

rapsli’s picture

Man... I always have to go on vacation if code gets fixed like this :) Good work. I just had a very quick look at it today. For the most part. So, I suggest, I'm going to make this the new version in alpha stage, then I'm gonna have to go through the queue and clean a little bit up. New version should be out tomorrow.

ncy’s picture

thanx :)

pimentoski’s picture

a great module and great team work!!!

btw, it's possible to put the image description in the thumbnail view in the bottom of each thumbnail?

rapsli’s picture

oky. next round is open...

lomz’s picture

How do I set the discription, I havent found that?

ncy’s picture

ncy’s picture

hi,

pimentoski, are you using the latest beta version?

lomz, you can edit EXIF descriptions using EXIFManager (free program): http://phgiraud.free.fr/exifmanager and set it in the admin section for caption display fields (General settings page)

Kiphaas7’s picture

One more thing, the active class isn't added to my fast gallery menu link when I add it to my primary or secondary links. Could this have anything to do with the module?

ncy’s picture

active class? what's that?

Kiphaas7’s picture

It's a css class that dynamically get's added to a link in the primary or secondary menu, corresponding to the page your visiting.

For example, if you're on the page "test", the menu code would show as following:

<ul>
   <li><a href="www.domain.com/home" class="">Home</a></li>
   <li><a href="www.domain.com/test" class="active">Test</a></li>
   <li><a href="www.domain.com/page" class="">Page</a></li>
</ul>

...providing visual confirmation in the menu to show you where you are.

This works for all my current modules, but yet it fails for the gallery. I was wondering if it was something I did wrong, or that it might be a setting/bug in the module itself.

ncy’s picture

oooh, i don't remember if the active class is set in the code. a lot of links are formed with l() function. i'll make a note of this on the list of things to-do when i get back.

rapsli’s picture

added the folderimage feature again -> user has the possibility to set an image to be displayed as folder (just like in win explorer). It's though still not finished.

Kiphaas7’s picture

ncy: I did some simple modules myself, and I don't recall setting the active class _myself_. I think it's something with the menu callback that goes wrong.

pimentoski’s picture

FileSize
108.02 KB

ncy i was not using the beta version... now everthing is fine, but:

- if you change the size of the thumbnail for a smaller size the text (description) will appear before the thumbnail at the left. Maybe if the text was center the problem does not happen . (look attachment file)

- the special characters not appear. If i wrote my first name "André" (like Andrew) it will appear "Andr", if i wrote something like "máquina" (machine) it will appear "m". but if i go to the sql and make and update to the field it works fine... this is very important for me and for all the people that no speak English (German, French, Portuguese, Brazilian, Spanish, and much more all have special characters)

thks

ncy’s picture

hi pimentoski, if you change the thumbnail size, you should update the CSS file's .single-image width accordingly. try that and let me know it that works better.

a lot of ppl have mentioned special characters already, i'll try to have a look at it next week.

pimentoski’s picture

ncy if i change the css it works fine, thks.

pimentoski’s picture

About the special characters i lost some of my time study php (i am a ASP, VB developer) and i discover this:

on the fast_gallery.class.php if you change the line 246 to

   $param['description'] = $exif['IFD0']['ImageDescription'];
   $param['description'] = mb_convert_encoding( $param['description'], "UTF-8");

the special characters disappear but the rest of the word stays ok.

for example a Portuguese word like "rígido" became "rgido" in your version "rígido" became "r"

but the good news is, if you add this in the line 246

    $param['description'] = $exif['IFD0']['ImageDescription'];
   
    $bad = array("ú", "ç", "ã", "á", "ê", "é", "ó", "í");
    $good   = array("ú", "ç", "ã", "á", "ê", "é", "ó", "Ã");

    $param['description'] = str_replace($bad, $good, $param['description']);

the string appear ok!!!!!!

EDITED: just put the line 246 like this and it will work fine (i guess)

    $param['description'] = mb_convert_encoding($exif['IFD0']['ImageDescription'], "UTF-8", "ISO-8859-1");
ncy’s picture

thanx for researching the special chars problem, pimentoski :)

rapsli’s picture

Status: Active » Fixed

committed to head

Anonymous’s picture

Status: Fixed » Closed (fixed)

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