We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24449
    • 81 Posts
    A little bit of logic could fix the naming but this started as a trivial bit of code written in 40mins to solve a quick problem wink Its on my expanding list of things to do, although Im not quite sure what a complete way round it would be, since just checking that the problem doesn’t exist wouldn’t preclude the possibility of someone adding a file later that DID clash.

    You are right about the modx db prefix, that came up for me last week and is top of the imaginary list of things to add in yet another release. Been a bit busy though as my daughter was born this morning after 15 hours of labour, so I haven’t actually slept for two days... wink


    Ramsay
      • 25663 MODX Staff
      • 12,272 Posts
      Congrats on your new family addition! laugh
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 9757
        • 82 Posts
        In the meantime I’ve made a lot of structural and functional changes in your original AutoGallery code. It still needs some clean-up here and there, but I think it’s working quite well.

        I’ve added:
        - support for gif format
        - now it respects modx table prefix and db charsets
        - now it adds entries into db smiley

        Of course it needs testing. All comments and suggestions are welcome smiley
          • 24449
          • 81 Posts
          Thanks for your efforts, fixedmachine!

          Looks like you’ve tidied up all the dodgy bits I had been meaning to do, and fixed all the bits where I needed to learn a few php tricks wink

          If its ok with you I’ll stick it up on our site as AG2.3 and try to work out how to use the MODx CMS ReleaseMe thingy again to put it on here.


          Ramsay
            • 9757
            • 82 Posts
            No problem smiley You can of course put it on your site! It’s on GPL isn’t it? laugh

            I thinking about some improvements though.

            I hope that my work will be useful for somebody smiley
              • 32756
              • 25 Posts
              I cannot for the life of me get AutoGallery to work properly. I’m using version 2.3, acquired today from http://www.zombietuesday.com

              I CAN get AutoGallery to create a single thumbnail, called "tn_.jpg" which it thinks is the name of all the thumbnails (obviously, that’s not right).

              My autogallerycall chunk looks like this:

              [!AutoGallery?itemchunk=`agItemChunk`&quality=`60`&tnwidth=`125`&tnheight=`125`&gallery=`15`!]


              and my agItemChunk looks like so:

              <hr><br />
              <a href="[+imgpath+]" rel="lightbox" title="[+title+]"/><img src="[+tnpath+]" alt="[+title+]" /></a>
              <br />
              debug: imgpath: [+imgpath+]
              <br />
              debug: tnpath: [+tnpath+]
              <br />
              debug: filename: [+filename+]
              <br />
              debug: thumburl: [+URLtnpath+]


              and the output of the debug portion of the call looks like this:

              debug: imgpath: assets/images/galleries/15/testimage00003.jpg
              debug: tnpath: assets/images/galleries/15/tn_.jpg
              debug: filename: testimage00003.jpg
              debug: thumburl: assets%2Fimages%2Fgalleries%2F15%2Ftn_.jpg
              


              Obviously, I’m very much trying to trouble shoot this most promising of snippets, but am not getting anywhere.

              This seems so much like it’s close to working, but that there is some sort of problem with the section of code that outputs the name of the thumbnail.

              Any ideas?

                • 32756
                • 25 Posts
                I love responding to my own posts. wink Seriously, I hope this helps someone.

                I am certainly no php guru, but I think I found the problem with version 2.3’s thumbnail generation code. Specifically, on line 162 where the thumbnail filename is created by concatenating several elements, I think there’s a bug.

                Currently, in version 2.3 of AutoGallery.inc.php, the code is like so:
                162: $params['tnpath'] = $gallerypath . '/tn_' . $path_parts['filename'];

                The problem is, $path_parts was declared only a few lines before in line 157 as:
                157: $path_parts = pathinfo($file);

                While $path_parts does contain something, $path_parts[’filename’] does not (at least on my system).

                The fix therefore is to change line 162 to read:
                $params['tnpath'] = $gallerypath . '/tn_' . $file;

                With this change made, the code does indeed create multiple thumbnail images AND returns a different filename for each image (rather important).

                Hope I’m on the right track here.
                  • 24449
                  • 81 Posts
                  Hi Wyleyrabbit,

                  Thats very strange! What OS and version of PHP are you using? I confess I have only tried this on our Linux server with PHP 5.2.9.

                  The workaround you suggests seems sensible, though. I’ll put it up later today.



                  Ramsay
                    • 32756
                    • 25 Posts
                    Hi Ramsay,

                    I’m on a Centos 4.8 server (same as Redhat Enterprise Linux), running PHP 5.1.6. The fix seemed to work great on this side, so I hope it helps someone.

                    Now, the next part I need to figure out is the best way to get the image descriptions into the mix. While I would be fine working with phpMyAdmin or similar, unfortunately that’s not a realistic solution for my client who will be creating the content.

                    So I was thinking that while there are likely many ways to get the data in there, the easiest solution would likely be a text file that is stored in the image gallery directory that would contain the name of the large image (ie. "testfile0003.jpg"), then a delimiter, then the description. Perhaps like so:

                    testfile0003.jpg | View from the entrance to the property.
                    testfile0027.jpg | The wine cellar is a great place to store your prized wines.
                    testfile0017.jpg | View of the master bedroom suite.
                    


                    Also, I was thinking that the file name could be specified as an argument passed along to the snippet.

                    Thoughts Ramsay? Or anyone else?

                    Cheers,
                    Wyleyrabbit
                      • 24449
                      • 81 Posts
                      Hi,

                      I have a set of pages and a snippet for uploading files including descriptions, and for modifying existing ones to add descriptions.

                      I’m packaging it up to port it to a new site of ours, so I can put it up once its working, if that would help?


                      Ramsay