We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22253
    • 54 Posts
    Quote from: j_p at Jun 14, 2009, 01:40 AM

    In case it helps anyone, I just thought I’d add in how I’ve managed to create square thumbs without using phpThumb.

    1/ In assets/snippets/maxigallery/css/default.css add the following to "ul.thumbs li":

    width:size-you-want px;
    height:size-you-want px;
    overflow:hidden;

    2/ In assets/snippets/maxigallery/watermark/Thumbnail.class.php, swap x and y around in line 264

    What this seems to do (I think I’m right - it works anyways) is make sure that that the shortest dimension is used when the image is resized - before the swapping the x and y around the largest was being used resulting in a rectangular thumb.

    The other larger dimension will then be masked by the overflow:hidden.



    Ok sorry I haven’t replied for a while. taken a bit of a break from the site. But I have tried your suggestion now of square thumbnails using the above instructions I found but I can’t seem to get the images to resize using the smaller width. This is affecting portrait images. A workaround has been to make the css crop a lot smaller, but then the thumbnails really are too small.

    What I need to be able to do is resize the images using the smaller dimension of the photo and also control centralise the thumbnail within the crop if you know what I mean? So that I always get a decent area of the photo showing in the thumbnail.
      • 7923
      • 4,213 Posts
      You need to make the square thumbnails with phpThumb and use it’s zoom crop feature.

      There are couple phx phpThumb modifiers available. Install those and use phpThumb in MaxiGallery templates.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 22253
        • 54 Posts
        Thanks Doze. I have attempted to install PHP Thumb but I really am a newb at this. I can’t work out whre to put the image.php file as part of the installation process.

        Before I delve deeper into this is this going to enable the user to upload photos and choose what shows in the thumbnail. Obviously I want it to be as automated as possible but is it a simple process using the zoom crop, even for my end users?
          • 7923
          • 4,213 Posts
          Well... The way I have installed phpThumb is following, this is littlebit different than maFF’s phx:phpThumb modifier. I use clean phpThumb package without modifications, so it can be updated by simply replacing files.

          1. Extract phpThumb package to: /assets/snippets/phpthumb/
          2. Create a snippet "phx:phpthumb":
          <?php
          $output = '/assets/snippets/phpthumb/phpThumb.php?src=' . $output . $options;
          return str_replace('&', '&', $output);
          ?>
          

          3. Call in maxigallery templates like this:
          <img src="[+phx:input=`[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]`:phpthumb=`&h=100&w=100&zc=1&q=95`+]" />
          



            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 22253
            • 54 Posts
            Hi again all,

            I always believe in trying to find the answer before seeking help but I am afraid I have failed in this instance - with several hours down the drain. It seems to be that A number of the forum posts do their best to help but they are targetted at more experienced modx users. As a result, sometimes critical pieces of information are left out or certain knowledge is assumed. I still believe there is mileage in having a HOWTO section in the forum with case studies for specific requirement - step by step that are tested and proven to work.

            Enter case in question - getting Phpthumb to work. The requirement is, I think fairly simple.

            Allow the user to upload and then select and image. This image is then dynamically resized within the page template so the user does not need to resize the image prior to reloading. The source image remains unchanged. Now I thought this was simple and it probably is, but I cannot get it to work. So, for those who are new and equally have the same problem and to show that I have tried, here are my actions step by step.

            1. Download the PHx package from http://modxcms.com/PHx-1006.html currently version 2.1.3 as I type.
            2. Created a directory called "phx" in the assets/plugins directory
            3. Copied all files and folders from within the Phx_2.1.3 folder into assets/plugins/phx directory - producing following structure.
            assets/plugins/phx/
            docs (folder)
            modifiers (folder)
            phx.parser.class.inc.php (file)
            phx.plugin.txt (file)
            4. Login to Manager
            5. Navigate to Resources->Manage Resources -> Plugins
            6. Create new plugin
            Plugin name: PHx

            3. Download the PhpThumb package from http://www.modxcms.com/phpThumb-Package-1522.html currently version 0.3 as I type.
            2. and select an image from the I have downloaded PHx and installed this.

            Ok I have done what you explained above but nothing is happening? I also found this guide but it seems to go about it completely differently. Also this may have been written before the newer version of ModX. I don’t quite understand how to implement this properly and how it works with my maxigallery callout.

            This is my maxigallery callout as it is

            [!MaxiGallery? &display=`embedded` &embedtype=`slimbox` &max_thumb_size=`80`  &max_pic_size=`0` &pics_per_page=`16`!]


            but I presume the code you gave for the maxigallery template replaces this? I have tried to find more out myself but a lot of the information presumes I know what I’m doing. smiley

            I have extracted the phpthumb package to /assets/snippets/phpthumb as well as the phx package to /assets/plugins as above and created the snippets you gave me. I’m not sure where to go next? The original maxigallery callout gave me the manage pictures button but nothing happens with this. I have probably missed out something really obvious.

            Sorry for all the questions. Really appreciate this.
              • 26849
              • 16 Posts
              Hi Phantom

              I’ve followed the method outlined by Doze and it works for me. I too had troubles getting phpthumb to work so I think it only right that I document what I have done so you can follow along. Thanks to Doze for his methodology!

              1. I downloaded the latest phpthumb package, 1.7.9 at the time of writing (http://sourceforge.net/projects/phpthumb/files/phpThumb%28%29/), and extracted it to: /assets/snippets/phpthumb/
              2. In the phpthumb folder rename the file "phpThumb.config.php.default" to "phpThumb.config.php"
              3. Create the snippet "phx:phpthumb" as directed by Doze’s post:
              <?php
              $output = '/assets/snippets/phpthumb/phpThumb.php?src=' . $output . $options;
              return str_replace('&', '&', $output);
              ?>

              4. In your MaxiGallery templates folder (/assets/snippets/maxigallery/templates) you need to modify the code which calls your thumbnails with that given by Doze:
              <img src="[+phx:input=`[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]`:phpthumb=`&h=100&w=100&zc=1&q=95`+]" class="thumbnail" />


              The template(s) you need to modify depend on what your gallery looks like. In your case the template you need to amend is "gallerypicturetpl.html". The code beginning at line 50 is:
              <img src="[(base_url)][+maxigallery.path_to_gal+]tn_[+maxigallery.picture.filename+]" class="thumbnail" title="[+maxigallery.picture.title:htmlent+] [+maxigallery.strings.click_to_zoom+]" alt="[+maxigallery.picture.title:htmlent+] [+maxigallery.strings.click_to_zoom+]" />

              and needs to be replaced as such:
              <img src="[+phx:input=`[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]`:phpthumb=`&h=100&w=100&zc=1&q=95`+]" class="thumbnail" title="[+maxigallery.picture.title:htmlent+] [+maxigallery.strings.click_to_zoom+]" alt="[+maxigallery.picture.title:htmlent+] [+maxigallery.strings.click_to_zoom+]" />


              Hopefully that should fix the problems you have been having smiley

              jb
                • 13373
                • 70 Posts
                jb2009,

                Thanks for the more detailed instructions - that’s really helpful.

                One small thing that caught me out was this part:
                <?php
                $output = '/assets/snippets/phpthumb/phpThumb.php?src=' . $output . $options;
                return str_replace('&', '&', $output);
                ?>

                which I’ve changed to:
                <?php
                $output = '[(base_url)]assets/snippets/phpthumb/phpThumb.php?src=' . $output . $options;
                return str_replace('&', '&', $output);
                ?>
                Note the base_url tag - this helps, particularly if your site is not at the root of your web directory.

                Cheers,
                Jacob

                EDIT (doze): Fixed the missing ] in base_url tag
                  • 22253
                  • 54 Posts
                  Cheers for all this guys.I’m going to implement this now so I’ll let you know how I get on.

                  Thanks again.
                    • 22253
                    • 54 Posts
                    Hi guys,
                    I have implemented the code supplied and it seems to be reading the correct file but my images have disappeared and I can see the html from the gallerypicture.tpl.

                    Could it be something in the maxigallery callout that is clashing with phpthumb? I noticed the height and width in the pdp are set to 100 each but I have dimensions set in my maxigallery callout too as per below.

                    [!MaxiGallery? &display=`embedded` &embedtype=`slimbox` &max_thumb_size=`80`  &max_pic_size=`0` &pics_per_page=`16`!]


                    This is the url to the text page I am working on at the moment.

                    http://www.squaredgepictures.co.uk/cmstemp/index.php?id=25

                    Sorry if these are really stupid questions, this has turned into a drawn out favour for someone. laugh
                    It’s an education at least.
                      • 7923
                      • 4,213 Posts
                      I don’t know why the MaxiGallery template is not parsed anymore.. Perhaps something happened to the file encoding when you edited the original template file or something like that. You can do custom templates in a chunk, so just create a new chunck with this content:

                      myGalleryPictureTpl
                      <li>
                         <a href="[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]" rel="lightbox[image[+maxigallery.pageinfo.id+]set]" title="[+maxigallery.picture.title:htmlent+] - [+maxigallery.picture.descr:htmlent+]">	
                            <img src="[+phx:input=`[(base_url)][+maxigallery.path_to_gal+][+maxigallery.picture.filename+]`:phpthumb=`&h=100&w=100&zc=1&q=95`+]" class="thumbnail" title="[+maxigallery.picture.title:htmlent+] [+maxigallery.strings.click_to_zoom+]" alt="[+maxigallery.picture.title:htmlent+] [+maxigallery.strings.click_to_zoom+]" />
                         </a>
                         <p style="width: [+maxigallery.picture_width_thumb+]px;">
                            [+maxigallery.picture.title:htmlent+]
                         </p>
                      </li>
                      


                      and then use it in your snippet call: &galleryPictureTpl=`myGalleryPictureTpl`

                      But it seems that phpThumb is not working in your server. You need to enable debug mode in it and try to fix it.


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."