We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30087
    • 23 Posts
    Yeah... you’re right.

    I can use the phpThumb connector from domain A on domain B to crop a picture from domain C.

    And I believe they are not being cached... can’t find the cached files.
      • 16040
      • 23 Posts
      So there is no way for creating thumbnails from a chunk or template? The GalleryTV is nice, but it would be nicer if you can specify the output of the thumbnail there and if you can link to the base image, too.
      "
      BTW: Why is the "gallery.phpthumb_path" linking to "...htdocs/modx/assets/components/phpthumb/" and not to the core-phpthumb-folder?
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        I imagine that the MiniPhoto snippet would work; all it does is get fed a URL to an image and the desired max dimensions, resize it, and return the URL of the resized version. I use it all the time in Ditto and Jot output tpls.
          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
          • 30107
          • 44 Posts
          Needed it today and made a short snippet as a first shot. It’s derived from the phpThumb package made for Evolution (http://modxcms.com/extras/package/341). Be warned: It’s not as comfortable as with phx. Please feel free to enhance - and post it back then.

          Usage:

          a) Install a vanilla phpThumb (get it here: http://phpthumb.sourceforge.net/#download)
          I installed it to /assets/snippets/phpThumb (path can be configured in the first line of the following snippet). Configure phpThumb with "high security" enabled, remember to set "high_security_password" too. Config file of phpThumb is "phpThumb.config.php" (has to be renamed from "phpThumb.config.php.default" first).

          b) Snippet - make a new snippet in Revo and call it "snpPhpThumb".

          <?php
          // relative path where phpThumb is installed -
          // modify this if you need to
          $strPath = 'assets/snippets/phpThumb';
          
          $strSrc = isset($image) ? $image : '';
          $strOptions = isset($options) ? $options : '';
          
          if ( !empty($strSrc) )
          {
          	// config file of phpThumb gets included
          	require_once($modx->getOption('base_path') . $strPath . '/phpThumb.config.php');
          
          	if(!empty($strOptions))
          	{
          		// options must begin with a &
          		if($strOptions[0] != '&') $strOptions = '&' . $strOptions;
          	}
          
          	$strParameter = 'src=' . $strSrc . $strOptions;
          
          	// generate hash for security
          	$strHash= md5($strParameter . @$PHPTHUMB_CONFIG['high_security_password']);
          	
          	// append hash to query
          	$strParameter .= '&hash=' . $strHash;
          	
          	// generate URL and return the result
          	return $modx->getOption('base_url') . $strPath . '/phpThumb.php' . '?' . $strParameter;
          }
          else
          {
          	return false;
          }
          ?>



          c) Call of snippet in your resource or template, for example:

          <img src="[[snpPhpThumb? &image=`/assets/images/mytestimage.jpg` &options=`w=400&h=300`]]" alt="" />
          


          Or use a TV:

          <img src="[[snpPhpThumb? &image=`[[*tvMyTestImage]]` &options=`w=400&h=300`]]" alt="" />
          


          Every option pf phpThumb can be used, see docs or demo (http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php)
            • 16040
            • 23 Posts
            Thank you very much. That’s what I wanted.

            BUT I’m getting an error!

            I’ve copied all files from version 1.7.9 to assets/snippets/phpThumb_1.7.9 and modified the path in the snippet.
            Calling the Image like you did, the sourcecode is also ok:

            <img src="/modx/assets/snippets/phpThumb_1.7.9/phpThumb.php?src=assets/resources/images/news/P1619[01]_24-05-10kl.jpg&w=664&hash=58966a99b21a322f0ebf9c5a50592a77" title="agsrgsrgsrg" alt="agegsgafaf"/>


            but the result is the error image with the message
            "homepages/..../htdocs/modx/assets/snippets/phpThumb_1.7.9/assets/resources/images/news/P1619[01]_24-05-10kl.jpg" does not exist

            Can you please help me?
              • 31906
              • 26 Posts
              Quote from: titanium at Jul 30, 2010, 11:20 AM

              Needed it today and made a short snippet as a first shot. It’s derived from the phpThumb package made for Evolution (http://modxcms.com/extras/package/341). Be warned: It’s not as comfortable as with phx. Please feel free to enhance - and post it back then.

              Usage:

              a) Install a vanilla phpThumb (get it here: http://phpthumb.sourceforge.net/#download)
              I installed it to /assets/snippets/phpThumb (path can be configured in the first line of the following snippet). Configure phpThumb with "high security" enabled, remember to set "high_security_password" too. Config file of phpThumb is "phpThumb.config.php" (has to be renamed from "phpThumb.config.php.default" first).

              b) Snippet - make a new snippet in Revo and call it "snpPhpThumb".

              <?php
              // relative path where phpThumb is installed -
              // modify this if you need to
              $strPath = 'assets/snippets/phpThumb';
              
              $strSrc = isset($image) ? $image : '';
              $strOptions = isset($options) ? $options : '';
              
              if ( !empty($strSrc) )
              {
              	// config file of phpThumb gets included
              	require_once($modx->getOption('base_path') . $strPath . '/phpThumb.config.php');
              
              	if(!empty($strOptions))
              	{
              		// options must begin with a &
              		if($strOptions[0] != '&') $strOptions = '&' . $strOptions;
              	}
              
              	$strParameter = 'src=' . $strSrc . $strOptions;
              
              	// generate hash for security
              	$strHash= md5($strParameter . @$PHPTHUMB_CONFIG['high_security_password']);
              	
              	// append hash to query
              	$strParameter .= '&hash=' . $strHash;
              	
              	// generate URL and return the result
              	return $modx->getOption('base_url') . $strPath . '/phpThumb.php' . '?' . $strParameter;
              }
              else
              {
              	return false;
              }
              ?>



              c) Call of snippet in your resource or template, for example:

              <img src="[[snpPhpThumb? &image=`/assets/images/mytestimage.jpg` &options=`w=400&h=300`]]" alt="" />
              


              Or use a TV:

              <img src="[[snpPhpThumb? &image=`[[*tvMyTestImage]]` &options=`w=400&h=300`]]" alt="" />
              


              Every option pf phpThumb can be used, see docs or demo (http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php)

              It doesn’t work if it’s called as parameter of other snippet. Trick is to add one line before include od phpthumb config file.
              	global $PHPTHUMB_CONFIG;
              	require_once($modx->getOption('base_path') . $strPath . '/phpThumb.config.php');
              
                • 17499 ☆ A M B ☆
                • 872 Posts
                Quote from: tinus at Jul 29, 2010, 08:29 AM

                Yeah... you’re right.

                I can use the phpThumb connector from domain A on domain B to crop a picture from domain C.

                And I believe they are not being cached... can’t find the cached files.

                Shouldn’t it be protected via htaccess ?
                  • 14951
                  • 151 Posts
                  I just made something yesterday that functions like your original request. I submitted it to the extras repository today, but I doubt it is available yet.

                  I have attached it to this post so you can give it a try. Let me know how it works for you!

                  -Jared

                  UPDATE: Fixed package upload
                    • 15162
                    • 59 Posts
                    Quote from: jtech at Aug 15, 2010, 01:20 PM

                    I just made something yesterday that functions like your original request. I submitted it to the extras repository today, but I doubt it is available yet.

                    I have attached it to this post so you can give it a try. Let me know how it works for you!

                    -Jared

                    UPDATE: Fixed package upload
                    Downloaded and loved it smiley Depending on where you are using this it could be beneficial to use &amp; instead of & to avoid validation errors. Thank you!
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Quote from: titanium at Jul 30, 2010, 11:20 AM

                      a) Install a vanilla phpThumb (get it here: http://phpthumb.sourceforge.net/#download)
                      I installed it to /assets/snippets/phpThumb (path can be configured in the first line of the following snippet). Configure phpThumb with "high security" enabled, remember to set "high_security_password" too. Config file of phpThumb is "phpThumb.config.php" (has to be renamed from "phpThumb.config.php.default" first).

                      Please be wary and aware that there is a major huge security hole in the phpThumb package on Sourceforge that give a great vector for script kiddies to p0wn your server. The implementation included in Revo is protected against this known vulnerability.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me