We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29661
    • 116 Posts
    Hello,

    Is here some way to get better url of my images in gallery that is using phpthumbof? My url of images looks like
    http://beta.e-lecba.cz/assets/components/gallery/connector.php?action=web/phpthumb&w=124&h=107&f=png&src=%2Fassets%2Fcomponents%2Fgallery%2Ffiles%2F2011%2F03%2Fbiolampa-biostimul-bs-103.jpg&fltr[]=wmt|e-lecba.cz|5|C|ffffff|||5|||100|0


    So all my images is named "connector.php" noone will find my images and my site by keywords...

    Is here any way to get url of images like http://mysite.com/assets/components/gallery/files/2/2011/biolampa.jpg?
      --
      John
      @theboxer
      • 33968
      • 863 Posts
      Yes there is!

      I had the same concern and found this great solution:
      http://mrphp.com.au/code/image-cache-using-phpthumb-and-modrewrite

      It’s more efficient too as it will only run phpThumb if the thumbnail does not already exist, rather than every time the image is requested.

      It will then store the thumbnail in a folder according to the image size, which can then be accessed using a ’friendly url’.

      The tutorial is fairly straightforward but let me know if you get stuck...
        • 29661
        • 116 Posts
        ha, it works great smiley thx
          --
          John
          @theboxer
          • 12241
          • 80 Posts
          Awesome!!! I’m back in the image resizing business.

          *note: I was getting 500 errors ’internal server misconfiguration...blah blah blah" because my directory permissions were not setup right on my assets/images folder. 755 works. In case anyone else run into that.
            Environment:
            modx: rev 2.0.8-pl
            localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37
            • 17301
            • 932 Posts
            I’m having trouble getting this to work.. Could you give a more in-depth step by step on whats needed to get this to work? I have friendly URLS setup for the rest of my site but can’t seem to get it to work for phpthumbof.

            Thanks!!
            LK
              ■ email: [email protected] | ■ website: https://alienbuild.uk

              The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
              • 12241
              • 80 Posts
              This method does not use phpthumbof ... just the standard phpthumb class, which has a security vulnerability that needs to be patched before you use it on a live site.

              I’ve attached a zip file that contains everything you need including a patched (per instructions on modx forums) version of phpthumb.

              Download the patched phpThumb (see attachment) and put in this location: /assets/components/phpthumb/.
              The patch fixes a security vulnerability that would otherwise leave your site open to a cross site scripting attack, if I remember correctly.

              Create a new folder in /assets/ folder called ’thumbs’

              Create an .htaccess file within this new thumbs folder and add the following:
              <IfModule mod_rewrite.c>
                RewriteEngine on
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php?thumb=$1 [L,QSA]
              </IfModule>
              



              Create the index.php Thumbnail Generator index file (see attached)
              The important parts of this file are the size declarations which must be entered here before you can begin making thumbnails of that size.
              //around line 10
              // define allowed image sizes
              $sizes = array(
              	'50x50',
              	'100x100',
              	'150x150',
              	'200x200'
              );
              


              and, the location of the phpThumb class:
              //around line 39
              require('../components/phpthumb/phpthumb.class.php');
              


              And that’s all that is needed to begin creating thumbs. The trick is to write your image tags in your modx templates like this:
              
              	<img src="assets/thumbs/100x100/[[+tv.thumbnail]]" alt="example" />
              


              and the thumbs/index.php file will create thumbs for you or serve up a thumb that was previously created.

              Hope this helps, oh yeah, and if you want you might want to delete the thumbs periodically which there is a script for and instructions at the original script author’s website as well as in the zip file I’ve attached which contains everything you need (including patched version of phpthumb).



                Environment:
                modx: rev 2.0.8-pl
                localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37
                • 12491
                • 90 Posts
                The attachment is 404, could you please splace another copy?

                grtz
                Hurby
                  Sommige mensen hebben aan een half woord genoeg
                  • 40553
                  • 42 Posts
                  I'm also having some concerns regarding the image url. Let's imagine a situation in which gallery with watermark applied to each image is created. An experienced user would be able to get to the image source file, delete the watermark variable from its url and viola-clean image is right at hand.

                  My question would be if there is any way to encode the image url so that is not meaningful to the viewer?
                    • 40387
                    • 28 Posts
                    Quote from: Hlight at Jul 02, 2011, 12:00 AM
                    This method does not use phpthumbof ... just the standard phpthumb class, which has a security vulnerability that needs to be patched before you use it on a live site.

                    I've attached a zip file that contains everything you need including a patched (per instructions on modx forums) version of phpthumb.

                    Download the patched phpThumb (see attachment) and put in this location: /assets/components/phpthumb/.
                    The patch fixes a security vulnerability that would otherwise leave your site open to a cross site scripting attack, if I remember correctly.

                    Create a new folder in /assets/ folder called 'thumbs'

                    Create an .htaccess file within this new thumbs folder and add the following:
                    <ifmodule mod_rewrite.c="">
                      RewriteEngine on
                      RewriteCond %{REQUEST_FILENAME} !-f
                      RewriteCond %{REQUEST_FILENAME} !-d
                      RewriteRule ^(.*)$ index.php?thumb=$1 [L,QSA]
                    </ifmodule>
                    



                    Create the index.php Thumbnail Generator index file (see attached)
                    The important parts of this file are the size declarations which must be entered here before you can begin making thumbnails of that size.
                    //around line 10
                    // define allowed image sizes
                    $sizes = array(
                    	'50x50',
                    	'100x100',
                    	'150x150',
                    	'200x200'
                    );
                    


                    and, the location of the phpThumb class:
                    //around line 39
                    require('../components/phpthumb/phpthumb.class.php');
                    


                    And that's all that is needed to begin creating thumbs. The trick is to write your image tags in your modx templates like this:
                    
                    	<img src="assets/thumbs/100x100/[[+tv.thumbnail]]" alt="example">
                    


                    and the thumbs/index.php file will create thumbs for you or serve up a thumb that was previously created.

                    Hope this helps, oh yeah, and if you want you might want to delete the thumbs periodically which there is a script for and instructions at the original script author's website as well as in the zip file I've attached which contains everything you need (including patched version of phpthumb).




                    503 Error

                    Page not found

                    The page you requested was not found.
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Where are you putting that .htaccess file? It needs to go in the assets/thumbs/ folder. oops... I see you are referring to the attachment to the post! You can get it from the original site, http://mrphp.com.au/blog/image-cache-using-phpthumb-and-modrewrite [ed. note: sottwell last edited this post 13 years, 10 months ago.]
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org