We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34109
    • 119 Posts
    I'm implementing an S3 media source in Revo 2.2. I can browse it fine, add to it and link images up. They all work fine on the front end, but phpthumb in the manager can't create thumbnails from them.

    Should it be able to?

    Here's what I get in the manager logs:
    [2012-02-09 16:28:20] (ERROR @ /var/www/vhosts/flaere.com/httpdocs/core/model/phpthumb/phpthumb.class.php : 3210) PHP warning: file_get_contents(http://d2194kovohby05.cloudfront.net/Albanian Bathers - Albania- 2006.jpg) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found

    [2012-02-09 16:28:20] (ERROR @ /connectors/system/phpthumb.php) phpThumb was unable to generate a thumbnail for: /var/www/vhosts/flaere.com/httpdocs/core/cache/phpthumb/phpThumb_cache_flaere.studiorepublic.com_src8b7bf961881f287f762865710590d5bc_paradf896d45f319fa323d889e84ccb98c5_dat0.jpeg
    [2012-02-09 16:28:20] (ERROR @ /connectors/system/phpthumb.php) Error outputting thumbnail:
    OutputThumbnail() failed because !is_resource($this->gdimg_output) in file "phpthumb.class.php" on line 557
      Studio Republic
      http://www.studiorepublic.com
      0845 226 3205
      @christodhunter
      • 34109
      • 119 Posts
      ...and although it says there's a 404 error I can access the file through a browser. Could it be that I'm using Cloudfront rather than connecting directly to the S3 instance?
        Studio Republic
        http://www.studiorepublic.com
        0845 226 3205
        @christodhunter
        • 34109
        • 119 Posts
        ...just tried with a new media source and a different http error butstill no thumbnail...

        [2012-02-09 16:35:33] (ERROR @ /var/www/vhosts/flaere.com/httpdocs/core/model/phpthumb/phpthumb.class.php : 3210) PHP warning: file_get_contents(http://flaere.artworks.s3.amazonaws.com/Albanian Bathers - Albania- 2006.jpg) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported

        [2012-02-09 16:35:34] (ERROR @ /connectors/system/phpthumb.php) phpThumb was unable to generate a thumbnail for: /var/www/vhosts/flaere.com/httpdocs/core/cache/phpthumb/phpThumb_cache_flaere.studiorepublic.com_srcaf7e52364ae3024358dcc2dfb37dcdd3_paradf896d45f319fa323d889e84ccb98c5_dat0.jpeg
        [2012-02-09 16:35:34] (ERROR @ /connectors/system/phpthumb.php) Error outputting thumbnail:
        OutputThumbnail() failed because !is_resource($this->gdimg_output) in file "phpthumb.class.php" on line 557
          Studio Republic
          http://www.studiorepublic.com
          0845 226 3205
          @christodhunter
          • 34109
          • 119 Posts
          OK - two pitfalls discovered...

          Creating folders and uploading files with CloudBerry explorer does something (god knows what) to the permissions - this causes 505 errors.

          Spaces in filenames cause the file-get-contents function to fall over causing the 404 error.

          So now, new question - I can't imagine many clients remembering for format their filenames without spaces so is there something that can be added to the phpthumb class to escape the url?
            Studio Republic
            http://www.studiorepublic.com
            0845 226 3205
            @christodhunter
            • 35844
            • 15 Posts
            You should never deploy files with spaces in the name, there's far too many potential compatibility issues. If you wish to escape them use %20, but I'd recommend advising your clients to use dashes or underscores.

            My Example File.rar

            Becomes...

            My%20Example%File.rar

            I can't comment on whether this will work as escaping in MODx or for the phpThumbOf interepter.
              • 34109
              • 119 Posts
              I don't name files with spaces but how ever much you try to educate a client there's only so much you can do! Is there any way to validate a file name through the modx browser when a user uploads does anyone know?
                Studio Republic
                http://www.studiorepublic.com
                0845 226 3205
                @christodhunter
                • 38339
                • 41 Posts
                Quote from: [email protected] at Feb 10, 2012, 02:58 AM
                I don't name files with spaces but how ever much you try to educate a client there's only so much you can do! Is there any way to validate a file name through the modx browser when a user uploads does anyone know?
                maybe this solution helps?
                  Revolution 2.2.6
                  • 34109
                  • 119 Posts
                  Looks good - question is, would that work with Amazon S3 uploads or just uploads to the local filesystem?
                    Studio Republic
                    http://www.studiorepublic.com
                    0845 226 3205
                    @christodhunter
                    • 35844
                    • 15 Posts
                    Ironically Chris, I'm now faced with the exact same issue you had with no Thumbnails being generated when browsing an S3 Bucket. Did you find a solution?
                      • 34109
                      • 119 Posts
                      It looks like permissions are a bit of a minefield with Amazon buckets. Make sure the bucket and the files are set to be publicly available and of course that the filenames are formatted correctly. I've found that uploading through modx or through my S3 control panel is fine, but using CloudBerry Explorer does something to the permissions which makes the files unreadable by phpthumb.

                      Hope this helps Ralph!
                        Studio Republic
                        http://www.studiorepublic.com
                        0845 226 3205
                        @christodhunter