We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37734
    • 17 Posts
    Thumbnails don't get generated when i upload an image to the new media source i created. But it does work when i connect this image TV to the default filesystem media source.

    The new mediasource called uploads has a basePath and a baseUrl to assets/uploads/. It's working fine when just uploading images.

    Here's the log when saving the TV with the image:

    [2012-01-25 00:57:36] (WARN @ /connectors/element/tv.php) xPDO->toCache() could not cache object with signature objects/modMediaSourceElement/f6c5f83ec4733b2ad51b56f3044ed90a
    [2012-01-25 00:57:48] (ERROR @ C:\domains\sitename.nl\wwwroot\core\model\phpthumb\phpthumb.class.php : 3210) PHP warning: file_get_contents(C:/domains/sitename.nl/wwwroot/assets/uploads/assets/uploads/modx-logo-color.png) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory
    [2012-01-25 00:57:48] (ERROR @ /connectors/system/phpthumb.php) phpThumb was unable to generate a thumbnail for: C:\domains\sitename.nl\wwwroot\core\cache\phpthumb\phpThumb_cache_www.sitename.nl_src11070200b91dcb398ce7c052ef4faf9a_paradf896d45f319fa323d889e84ccb98c5_dat0.jpeg
    [2012-01-25 00:57:48] (ERROR @ /connectors/system/phpthumb.php) Error outputting thumbnail:
    OutputThumbnail() failed because !is_resource($this->gdimg_output) in file "phpthumb.class.php" on line 557


    I noted that "assets/uploads" in the log is printed twice in one link.

    Hope someone can give me a pointer in how to fix this.

    Kind regards,

    Mayhem

    This question has been answered by mayhem_1980. See the first response.

    [ed. note: mayhem_1980 last edited this post 14 years, 8 months ago.]
      • 28215
      • 4,149 Posts
      Post your basePath and baseUrl settings for the Media Source.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 37734
        • 17 Posts
        basePath: assets/uploads/
        basePathRelative: Yes
        baseUrl: assets/uploads/
        baseUrlRelative: Yes
        • discuss.answer
          • 37734
          • 17 Posts
          Today I decided to have another look and it seems i don't get the error while saving the image anymore. I don't know why. So here's the thing now:

          The thumbs appear in /core/cache/phpthumb/ but when i go load the page on the front-end the images don't appear. This is what i get: <img src="./IMG_1986.jpg">

          When i go to modx_site_tmplvar_contentvalues in phpmyadmin the value is: ./IMG_1986.jpg. When I edit this value to: assets/uploads/IMG_1986.jpg the correct thumb loads on the front-end. This is what i get now: <img src="/assets/components/phpthumbof/cache/8ce3ffda4918898d47134c4e8c6f0924.f4fdf237f8a97bdaddedaa8b4e0ba5da.jpg">

          But in the backend where you place the TV, the path is now wrong.


          When I change the value in de DB back to the original and I load the page on the front-end I get the following log:

          [2012-01-26 15:55:02] (ERROR @ /media/data/www/mediation/core/model/phpthumb/phpthumb.class.php : 1330) PHP warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known
          [2012-01-26 15:55:02] (ERROR @ /media/data/www/mediation/core/model/phpthumb/phpthumb.class.php : 1330) PHP warning: getimagesize(http://mediation./IMG_1986.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
          [2012-01-26 15:55:02] (ERROR @ /media/data/www/mediation/core/model/phpthumb/phpthumb.class.php : 1330) PHP warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known
          [2012-01-26 15:55:02] (ERROR @ /media/data/www/mediation/core/model/phpthumb/phpthumb.class.php : 1330) PHP warning: getimagesize(http://mediation./IMG_1986.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
          [2012-01-26 15:55:02] (ERROR @ /media/data/www/mediation/core/model/phpthumb/phpthumb.class.php : 3228) PHP warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
          [2012-01-26 15:55:02] (ERROR @ /media/data/www/mediation/core/model/phpthumb/phpthumb.class.php : 3228) PHP warning: file_get_contents(http://mediation./IMG_1986.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
          [2012-01-26 15:55:02] (ERROR @ /index.php) [phpThumbOf] Could not generate thumbnail: http://mediation./IMG_1986.jpg - Debug: Array
          (
              [0] => phpThumb() v1.7.9-200712090829 in file "phpthumb.class.php" on line 216
              [1] => setCacheDirectory() starting with config_cache_directory = "/media/data/www/mediation/core/cache/phpthumb/" in file "phpthumb.class.php" on line 937
              [2] => setting config_cache_directory to realpath(/media/data/www/mediation/core/cache/phpthumb) = "/media/data/www/mediation/core/cache/phpthumb" in file "phpthumb.class.php" on line 965
              [3] => setCacheDirectory() starting with config_cache_directory = "/media/data/www/mediation/assets/components/phpthumbof/cache/" in file "phpthumb.class.php" on line 937
              [4] => setting config_cache_directory to realpath(/media/data/www/mediation/assets/components/phpthumbof/cache) = "/media/data/www/mediation/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 965
              [5] => setSourceFilename(http://mediation./IMG_1986.jpg) set $this->sourceFilename to "http://mediation./IMG_1986.jpg" in file "phpthumb.class.php" on line 261
              [6] => skipping CleanUpCacheDirectory() set to purge (30.0 days; 100.00MB; 10,000 files) in file "phpthumb.class.php" on line 670
              [7] =>   file_exists() = 0 in file "phpthumb.class.php" on line 1119
              [8] => is_executable() = 0 in file "phpthumb.class.php" on line 1120
              [9] => using ImageMagick path from `which convert` (/usr/bin/convert) in file "phpthumb.class.php" on line 1139
              [10] => ImageMagick version checked with "convert --version" in file "phpthumb.class.php" on line 1166
              [11] => ImageMagick did not return recognized version string (Version: ImageMagick 6.6.0-4 2011-06-15 Q16 http://www.imagemagick.org
          Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
          Features: OpenMP) in file "phpthumb.class.php" on line 1172
              [12] => ImageMagick convert --version says "Unknown" in file "phpthumb.class.php" on line 1175
              [13] => $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 902
              [14] => $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 913
              [15] => $this->thumbnailFormat set to $this->f "jpeg" in file "phpthumb.class.php" on line 920
              [16] => $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 930
              [17] => $this->sourceFilename set to "http://mediation./IMG_1986.jpg" in file "phpthumb.class.php" on line 831
              [18] => setCacheDirectory() starting with config_cache_directory = "/media/data/www/mediation/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 937
              [19] => setting config_cache_directory to realpath(/media/data/www/mediation/assets/components/phpthumbof/cache) = "/media/data/www/mediation/assets/components/phpthumbof/cache" in file "phpthumb.class.php" on line 965
              [20] => SetCacheFilename() _src set from md5($this->sourceFilename) "http://mediation./IMG_1986.jpg" = "d36472cf7a4e089c7bfce98ea8e45cf2" in file "phpthumb.class.php" on line 3095
              [21] => SetCacheFilename() _par set from md5(_farC_zc1_h69_w69_dpi150_q75) in file "phpthumb.class.php" on line 3128
              [22] => starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 2915
              [23] => GetImageSize("http://mediation./IMG_1986.jpg") failed in file "phpthumb.class.php" on line 2938
              [24] => $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1250
              [25] => phpThumb_tempnam() returning "/media/data/www/mediation/pThumb9NyqB6" in file "phpthumb.class.php" on line 3879
              [26] => ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1207
              [27] => ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1207
              [28] => GetImageSize(http://mediation./IMG_1986.jpg) FAILED with error "" in file "phpthumb.class.php" on line 1336
              [29] => GetImageSize(http://mediation./IMG_1986.jpg) failed in file "phpthumb.class.php" on line 1478
              [30] => Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 1825
              [31] => ImageMagickSwitchAvailable(quality;interlace) = 1 in file "phpthumb.class.php" on line 1204
              [32] => ImageMagick called as (convert -density 150 -thumbnail 69x69 -quality 75 -interlace line  "http://mediation./IMG_1986.jpg[0]" jpeg:"/media/data/www/mediation/pThumb9NyqB6" 2>&1) in file "phpthumb.class.php" on line 1844
              [33] => ImageMagick failed with message (error : No such file or directory
          convert: no decode delegate for this image format `/tmp/magick-XXWzy1yN' @ error/constitute.c/ReadImage/533.
          convert: no data returned `http://mediation./IMG_1986.jpg' @ error/url.c/ReadURLImage/226.
          convert: missing an image filename `jpeg:/media/data/www/mediation/pThumb9NyqB6' @ error/convert.c/ConvertImageCommand/2940.) in file "phpthumb.class.php" on line 1852
              [34] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 2945
              [35] => SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 2894
              [36] => SetOrientationDependantWidthHeight() setting w="69", h="69" in file "phpthumb.class.php" on line 2910
              [37] => EXIF thumbnail extraction: (size=0; type=""; 0x0) in file "phpthumb.class.php" on line 2997
              [38] => starting SourceImageToGD() in file "phpthumb.class.php" on line 3247
              [39] => $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1250
              [40] => phpThumb_tempnam() returning "/media/data/www/mediation/pThumbsSj6RW" in file "phpthumb.class.php" on line 3879
              [41] => ImageMagickSwitchAvailable(thumbnail) = 1 in file "phpthumb.class.php" on line 1207
              [42] => ImageMagickSwitchAvailable(density) = 1 in file "phpthumb.class.php" on line 1207
              [43] => GetImageSize(http://mediation./IMG_1986.jpg) FAILED with error "" in file "phpthumb.class.php" on line 1336
              [44] => GetImageSize(http://mediation./IMG_1986.jpg) failed in file "phpthumb.class.php" on line 1478
              [45] => Remaining $this->fltr after ImageMagick: (array(0) { } ) in file "phpthumb.class.php" on line 1825
              [46] => ImageMagickSwitchAvailable(quality;interlace) = 1 in file "phpthumb.class.php" on line 1204
              [47] => ImageMagick called as (convert -density 150 -thumbnail 69x69 -quality 75 -interlace line  "http://mediation./IMG_1986.jpg[0]" jpeg:"/media/data/www/mediation/pThumbsSj6RW" 2>&1) in file "phpthumb.class.php" on line 1844
              [48] => ImageMagick failed with message (error : No such file or directory
          convert: no decode delegate for this image format `/tmp/magick-XXBGEorb' @ error/constitute.c/ReadImage/533.
          convert: no data returned `http://mediation./IMG_1986.jpg' @ error/url.c/ReadURLImage/226.
          convert: missing an image filename `jpeg:/media/data/www/mediation/pThumbsSj6RW' @ error/convert.c/ConvertImageCommand/2940.) in file "phpthumb.class.php" on line 1852
              [49] => starting ImageCreateFromFilename(http://mediation./IMG_1986.jpg) in file "phpthumb.class.php" on line 3170
              [50] => empty $filename or GetImageSize(http://mediation./IMG_1986.jpg) failed in file "phpthumb.class.php" on line 3219
              [51] => Populating $rawimagedata in file "phpthumb.class.php" on line 3227
              [52] => cannot fopen(http://mediation./IMG_1986.jpg) in file "phpthumb.class.php" on line 3230
              [53] => Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3296
              [54] => $this->gdimg_source is still empty in file "phpthumb.class.php" on line 3348
              [55] => ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3350
              [56] => phpThumb() v1.7.9-200712090829
          
          Unknown image type identified by "" () in SourceImageToGD()[3462] in file "phpthumb.class.php" on line 3665
              [57] => SourceImageToGD() failed in file "phpthumb.class.php" on line 341
          )


          I already updated to 1.3.1 of phpthumbof btw.
            • 37734
            • 17 Posts
            So I created this rather horrible solution:

            The first time you upload an image it's called e.g. "filename.jpg"
            After that it's called "./filename.jpg"

            I changed the phpthumbof snippet, I added the folling code before $thumbnail->setInput($input);

            preg_match('/^.\//', $input, $matches);
            
            if (!empty($matches)) {    
                $input = str_replace("./", "/assets/uploads/", $input);
            } else {
                $input = "/assets/uploads/" . $input;
            }


            This is however not an acceptable fix and I think there is still some weird base_path stuff going on.

              • 36722
              • 101 Posts
              @mayhem_1980 I'm seeing the same issue, I have since version 2.0.x

              Only solution for me was to not use a prepending path and let the file browser do the whole thing, however this means manually selecting /assets/images in the image browser.

              http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types#TemplateVariableInputTypes-Image This here has NEVER worked. I've never seen it prefix the image name.
                Shawn Himmelberger
                Himmelberger Design
                https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Design | https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Development
                • 36722
                • 101 Posts
                Ok with the help of the boys in IRC and OpenGeek he let me know you need &processTVs=`1` set in your get resources call. then it works.
                  Shawn Himmelberger
                  Himmelberger Design
                  https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Design | https://himmdesign.com/services/website-development/modx"" target="_blank" rel="nofollow"> MODx Web Development