We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10713
    • 41 Posts
    I guess in the last version of phpthumbof, there was a bug with the automatic type detection, which is now fixed. Maybe I could drop the explicit parameter now...

    Does the plugin now work with spaces in file names? Didn’t test it myself.
      • 30107
      • 44 Posts
      Quote from: gerritvanaaken at Jun 15, 2011, 02:51 AM

      I guess in the last version of phpthumbof, there was a bug with the automatic type detection, which is now fixed. Maybe I could drop the explicit parameter now...

      Does the plugin now work with spaces in file names? Didn’t test it myself.
      Yes, it works as intended.
      Another idea: wouldn’t it be good if the phpthumb options string could be optionally customized?
      $image['options'] = "f=".$filetype."&h=".$height."&w=".$width;

      I ran into the problem that I had to add "&zc=1" (zoom crop) to it. After the update, my modification was overwritten and I had to do it again.
        • 10713
        • 41 Posts
        What was the problem without "zoom crop"? Can you explain why an option would be useful? I can’t get the point here...
          • 30107
          • 44 Posts
          Quote from: gerritvanaaken at Jun 16, 2011, 03:18 AM

          What was the problem without "zoom crop"? Can you explain why an option would be useful? I can’t get the point here...
          "Zoom crop" is a very useful option offered by phpthumb. It can be triggered by adding "&zc=1" to the phpthumb config string. For example, if you’ve got a couple of images which have slightly different sizes, but you want them to be equal in width and height, then you can use "&zc=1" and every picture is fitted well in the given sizes by cropping some height or some width of the picture, according to the ratio of width/height. Without zoom crop, there would be white borders on the left and right or top and bottom of the picture. Zoom crop makes image galleries look nice, for example.

          Another useful option of phpthumb are rounded corners, and much more. The phpthumb Website offers some examples which demonstrate the ideas behind.

          Maybe this config string (you’re using f=".$filetype."&h=".$height."&w=".$width by default) could be overriden by a configurable property of your plugin.
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            I will also vouch for making phpthumb params configurable. There’s a great deal of power in there which can be achieved by combining certain params.

            You could also allow sort of placeholders to be used then ( {width} to be replaced with the width from the img tag, {height} etc) which you simply add with str_replace.
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 10713
              • 41 Posts
              I’m still not getting the point! The only phpthumb option I could image for the plugin would be the compression level. The idea behind AutoFixImageSize is to leave the visual presentation of all images untouched and only reduce file size. Adding "cropping/zooming/whatever" would lead to different results, right? Please illustrate your feature request with pictures if necessary.

              To say it in German: I’n standing on a Schlauch ;-)
                • 34022 ☆ A M B ☆
                • 91 Posts
                Super easy way to allow certain images to be ignored by the plugin: just have it skip all images with GET parameters.


                // ...
                $img_old = $filenames[0][$i];
                if (strpos(’?’,$filename)) continue; // just add this line
                // ...

                    $img_old = $filenames[0][$i];
                    if (strpos($filename,'?')) continue; // just add this line
                


                Not only does this prevent broken phpthumb links, but any image with a GET parameter is probably not a static image and should be skipped anyways. And if anyone wants to do super-custom phpthumb transformations, they can just tack on a GET parameter to force the image to be ignored and use phpthumbof (from the repository) or their own custom code:

                <img src="[[*image:phpthumbof=`w=100`]]?v=skipthis" width="100" />


                I came up with this because I use GET parameters to prevent browsers from using the cached version of certain images.
                  WebsiteZen.com - MODX and E-Commerce web development in the San Francisco Bay Area
                  • 34022 ☆ A M B ☆
                  • 91 Posts
                  Whoops, that should be:

                  <?php
                  // ...
                      $img_old = $filenames[0][$i];
                      if (strpos($filename,'?')) continue; // just add this line
                  // ...
                  
                    WebsiteZen.com - MODX and E-Commerce web development in the San Francisco Bay Area
                    • 30107
                    • 44 Posts
                    Quote from: gerritvanaaken at Jun 17, 2011, 01:45 AM

                    I’m still not getting the point! The only phpthumb option I could image for the plugin would be the compression level. The idea behind AutoFixImageSize is to leave the visual presentation of all images untouched and only reduce file size. Adding "cropping/zooming/whatever" would lead to different results, right? Please illustrate your feature request with pictures if necessary.

                    To say it in German: I’n standing on a Schlauch ;-)

                    Gerrit, in German too: you are heavy on wire smiley
                    Okay, I try to explain my feature request in other words: if you are assembling a image gallery with some pictures, which don’t have all the same width/height ratio, the image gallery looks some kind of ugly, right? Because the result is a tableau of pictures which are unequal in width or in height. This is where zoom crop is useful: most of the time the important ares of an image are in the center; so it doesn’t matter if some pixels to the top and bottom or to the left and right are cut off. This is what zoom crop does: it gives images a certain width/height ratio. Without zoom crop, you get black bars on top and bottom (when the source picture is not tall enough in order to fit in the desired with/height ratio) or it becomes black bars on the left and the right (if the source picture is not wide enough).

                    Try it yourself: select a picture in TinyMCE, set a certain width/height ratio (given the source picture is 300x200 pixel, set explicitly 300x260 pixel), and see what AutoFixImageSize gives... it adds black bars smiley Isn’t that a change of the visual presentation too...?
                      • 10713
                      • 41 Posts
                      Okay, now that’s clear to me! I never really tried to change the aspect ratio of the TinyMCE-embedded images (my designer heart hurts so much doing that).

                      In the first step, I will change the default setting to mimic standard browser behaviour (effectively stretching those images).

                      In the second step (version 1.1) I’ll add options to let you decide what to do with wrong aspect ratio images, plus compression quality!