On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Phpthumb works fine with my TV’s - but I have a rails app that my client is using to upload photos.

    These photos are stored outside of the modx directory (a few steps above). But i have created a symlink inside of the modx directory to these images.


    These photos are referenced using Rowboat which uses a chunk as a template. For example

    <img scr="assets/symlinkfolder/[[+pathtoimage:phpthumbofcode]]" />

    At first after viewing error messages saying that phpthumb couldnt find the file I assumed phpthumb was only processing [[+pathtoimage]] rather than the URL information infront of it (assets/sysmlinkfolder/)

    However I DID try it with just a tv <img scr="[[tv.myimagetv:phpthumbofcode]]" /> but it doesn’t work. I pointed the TV inside of the symlink to the files.

    Any help would be greatly appreciated. As always, will try to figure it out myself and post back.
    • Schoolboy error: <img src not scr smiley

      • *bows*

        unfortunately that is not the error - just a typo in my post
        • Ok smiley

          First, remove the phpThumbOf extender and just check that the full image loads correctly. At least then you will know that the paths are correct.
          At first after viewing error messages saying that phpthumb couldnt find the file I assumed phpthumb was only processing [[+pathtoimage]] rather than the URL information infront of it (assets/sysmlinkfolder/)
          Your assumption was correct there, you will need to include the full image path including ’assets/symlinkfolder/’ in your image tv, otherwise I don’t see how phpThumb is going to find them. Is the image folder publicly accessible?

          Second, check your error log in modx manager and find the entry generated by phpThumbOf. There have been some path issues when modx is installed outside of the root folder; there may be a similar issue in your case here. You’ll get an idea of what the problem might be in the log - feel free to post it here if you’re still stuck!
          • I guess the key here is that i’m NOT using a TV. I’m using Rowboat and grabbing part of the url from the database [[+databasefield:phpthumb]]

            The problem, as you stated is that phpthumb is only rendering the part of the url the database field has stored.

            So how do I run phpthumb with the entire url for example <img src=/firstpartofPath/[[+pathtoimage-fromdatabase:phpthumbof]] />

            I guess a snippet melding the two would be the answer ? Anything easier?
            • phpThumbOf has been set up to be used as an Output Modifier, so it is looking for a parameter $input containing the image path, and $options to contain the thumbnail settings.

              I guess you could get around the path issue by using a regular snippet call like this:
              <img src="[[!phpthumbof? &input=`/firstpartofPath/[[+pathtoimage]]` &options=`w=300&h=300&zc=1`]]" />
              

              I haven’t tested it but I don’t see why that wouldn’t work. Try it out and I’m happy to help if it needs further troubleshooting. Don’t forget that detailed error log either wink
              • Here is the wonderful error. I think the REAL problem is the symlink to the image folder is outside of the modx root

                I will test and report back. Thanks for the idea about the snippet call. Solved 1 of my issues smiley


                [2011-05-07 13:08:42] (ERROR @ /index.php) [phpThumbOf] Could not generate thumbnail: assets/newpetimages/173/original/ROSWELL.jpg - Debug: Array
                (
                    [0] => phpThumb() v1.7.9-200712090829 in file "phpthumb.class.php" on line 216
                    [1] => setCacheDirectory() starting with config_cache_directory = "/home/foha/domains/foha.org/public_html/core/cache/phpthumb/" in file "phpthumb.class.php" on line 919
                    [2] => setting config_cache_directory to realpath(/home/foha/domains/foha.org/public_html/core/cache/phpthumb) = "/home/foha/domains/foha.org/public_html/core/cache/phpthumb" in file "phpthumb.class.php" on line 947
                    [3] => setCacheDirectory() starting with config_cache_directory = "/home/foha/domains/foha.org/public_html/assets/components/phpthumbof/cache/" in file "phpthumb.class.php" on line 919
                    [4] => setting config_cache_directory to realpath(/home/foha/domains/foha.org/public_html/assets/components/phpthumbof/cache) = "/home/foha/domains/foha.org/public_html/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 947
                    [5] => setSourceFilename(assets/newpetimages/173/original/ROSWELL.jpg) set $this->sourceFilename to "assets/newpetimages/173/original/ROSWELL.jpg" in file "phpthumb.class.php" on line 243
                    [6] => skipping CleanUpCacheDirectory() set to purge (30.0 days; 100.00MB; 10,000 files) in file "phpthumb.class.php" on line 652
                    [7] => $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 884
                    [8] => $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 895
                    [9] => $this->thumbnailFormat set to $this->f "png" in file "phpthumb.class.php" on line 902
                    [10] => $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 912
                    [11] => !$this->config_allow_src_above_docroot therefore setting "/home/foha/domains/foha.org/foha/public/system/mainimages/173/original/ROSWELL.jpg" (outside "/home/foha/domains/foha.org/public_html") to null in file "phpthumb.class.php" on line 1066
                    [12] => $this->sourceFilename set to "" in file "phpthumb.class.php" on line 813
                    [13] => phpThumb() v1.7.9-200712090829
                
                "" does not exist in file "phpthumb.class.php" on line 3647
                    [14] => setCacheDirectory() starting with config_cache_directory = "/home/foha/domains/foha.org/public_html/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 919
                    [15] => setting config_cache_directory to realpath(/home/foha/domains/foha.org/public_html/assets/components/phpthumbof/cache) = "/home/foha/domains/foha.org/public_html/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 947
                    [16] => !$this->config_allow_src_above_docroot therefore setting "/home/foha/domains/foha.org/foha/public/system/mainimages/173/original/ROSWELL.jpg" (outside "/home/foha/domains/foha.org/public_html") to null in file "phpthumb.class.php" on line 1066
                    [17] => SetCacheFilename() _src set from md5($this->sourceFilename) "" = "d41d8cd98f00b204e9800998ecf8427e" in file "phpthumb.class.php" on line 3077
                    [18] => SetCacheFilename() _par set from md5(_farC_zc1_h115_w116_dpi150) in file "phpthumb.class.php" on line 3110
                    [19] => starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 2897
                    [20] => GetImageSize("") failed in file "phpthumb.class.php" on line 2920
                    [21] => $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1232
                    [22] => ImageMagickThumbnailToGD() aborting because $this->sourceFilename is empty in file "phpthumb.class.php" on line 1279
                    [23] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 2927
                    [24] => SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 2876
                    [25] => SetOrientationDependantWidthHeight() setting w="116", h="115" in file "phpthumb.class.php" on line 2892
                    [26] => exif_thumbnail() does not exist, cannot extract EXIF thumbnail in file "phpthumb.class.php" on line 2974
                    [27] => starting SourceImageToGD() in file "phpthumb.class.php" on line 3229
                    [28] => $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1232
                    [29] => ImageMagickThumbnailToGD() aborting because $this->sourceFilename is empty in file "phpthumb.class.php" on line 1279
                    [30] => Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3278
                    [31] => $this->gdimg_source is still empty in file "phpthumb.class.php" on line 3330
                    [32] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3332
                    [33] => phpThumb() v1.7.9-200712090829
                
                Unknown image type identified by "" () in SourceImageToGD()[3444] in file "phpthumb.class.php" on line 3647
                    [34] => SourceImageToGD() failed in file "phpthumb.class.php" on line 323
                )
                • Glad that worked! Looking at the errors from [11] down, I think you are right about the paths pointing outside the root.

                  I do have an idea how you might get around this:

                  *** EDIT - removed, see system settings in post below ***

                  That might do it but I can’t be sure and haven’t tested it. You might want to look at some of the other config options there too.
                  • Before you do anything!! I just found that setting in the system settings, so no need to touch that php file.

                    Just search for ’phpthumb’. The first option setting_phpthumb_allow_src_above_docroot - change that to true. No upgrade worries that way either tongue
                    • Done and Done. Fixed. Thanks for the help!