We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38090
    • 53 Posts
    Thumbnails aren't displaying within the Modx Manager:

    I'm having a problem within Manager where thumbs aren't displaying.


    I've clicked on the thumbnail to view source:
    http://www.scorchsoft.com/connectors/system/phpthumb.php?h=150&w=150&src=portfolio-img.jpg&source=1
    Note: You will need to add 212.78.67.137 scorchsoft.com to your hosts file to view the site at the moment as I'm developing via proxy
    As you can see, I'm currently getting an internal server error

    What is interesting is that if I use the phpThumbOf extension on the front end of the site then it works fine. E.g. the image on this page is driven using phpThumb:
    http://www.scorchsoft.com/index.php?id=2

    Things I have tried:

    • altering various phpthumb settings including the access of files outside of root.
    • Re-installing imagemagick.
    • Checking and altering folder permissions on the server.
    • Checking that the server document root variable is correct.
    (I've also done a lot of Google Searching to try and find the answer)

    Here is the phpinfo for the server:
    http://www.scorchsoft.com/i.php

    What is also interesting is that the Modx error log is empty.

    I'll be very great-full if you could point me in the right direction on this issue as I've been unable to pinpoint the problem. [ed. note: scorchsoft last edited this post 10 years, 10 months ago.]
      • 38090
      • 53 Posts
      I have some more insight into this issue and it is a really odd one. I have now enabled friendly URL's and the outcome is interesting.

      If I visit:
      http://www.scorchsoft.com/connectors/system/phpthumb.php?src=portfolio-img.jpg&w=913
      Then I get served the HTML for the home page

      If I visit:
      http://www.scorchsoft.com/connectors/system/phpthumb.php?src=portfolio-img.jpg&w=1000
      then the image renders successfully.

      If I visit:
      http://www.scorchsoft.com/connectors/system/phpthumb.php?src=portfolio-img.jpg&w=914
      The image also renders correctly.

      So it's as if phpthumb is erroring if it has to reduce the image size down much more than the originally uploaded image. (The original image is 1000px wide) I can increase the image size as much as I like in the URL parameter with no error.

      I have also tried reducing the size of the phphumbed image on the front end pages, but this doesn't error. It is only the phpthumb file within the connectors/system folder that is having this issue.
        • 38090
        • 53 Posts
        OK I have found a solution but is is a major hack!

        So I visited /connectors/system/phpthumb.php and found the following code:


        
        <?php
        /**
         * @var modX $modx
         * @package modx
         */
        require_once dirname(dirname(__FILE__)).'/index.php';
        $_SERVER['HTTP_MODAUTH'] = $modx->user->getUserToken($modx->context->get('key'));
        $modx->request->handleRequest(array('location' => 'system','action' => 'phpthumb'));
        
        


        If figured if the Gallery modules functionality was working and the above code wasn't then maybe I could make this file go through the Gallerys phpthumb process. So I found the connector for the gallery (assets/components/gallery/connector.php), tweaked some of its code and copied it into "/connectors/system/phpthumb.php"

        So now my file at /connectors/system/phpthumb.php looks like this:


        
        <?php
        /**
         * @var modX $modx
         * @package modx
         */
        require_once dirname(dirname(__FILE__)).'/index.php';
        
        //force the url action to always be web/phpthumb
        $_REQUEST['action'] = 'web/phpthumb';
        
        if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'web/phpthumb') {
            @session_cache_limiter('public');
            define('MODX_REQP',false);
        }
        require_once dirname(dirname(__FILE__)).'/config.core.php';
        require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
        require_once MODX_CONNECTORS_PATH.'index.php';
        
        $galleryCorePath = $modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/');
        require_once $galleryCorePath.'model/gallery/gallery.class.php';
        $modx->gallery = new Gallery($modx);
        
        $modx->lexicon->load('gallery:default');
        
        if ($_REQUEST['action'] == 'web/phpthumb') {
            $version = $modx->getVersionData();
            if (version_compare($version['full_version'],'2.1.1-pl') >= 0) {
                if ($modx->user->hasSessionContext($modx->context->get('key'))) {
                    $_SERVER['HTTP_MODAUTH'] = $_SESSION["modx.{$modx->context->get('key')}.user.token"];
                } else {
                    $_SESSION["modx.{$modx->context->get('key')}.user.token"] = 0;
                    $_SERVER['HTTP_MODAUTH'] = 0;
                }
            } else {
                $_SERVER['HTTP_MODAUTH'] = $modx->site_id;
            }
            $_REQUEST['HTTP_MODAUTH'] = $_SERVER['HTTP_MODAUTH'];
        }
        
        /* handle request */
        $path = $modx->getOption('processorsPath',$modx->gallery->config,$galleryCorePath.'processors/');
        $modx->request->handleRequest(array(
            'processors_path' => $path,
            'location' => '',
        ));
        
        


        And how it works perfectly.

        Note: If you are having the same problem then you will need to make sure that the gallery plugin has been installed. I am currently running Modx Revo 2.2.6-pl and the gallery plugin that I have installed is 1.5.2 (pl). I also have phpThumbOf 1.4.0 (pl) installed but I don't think that this plugin is involved in this fix in any way as Gallery appears to have its own phpthumb configuration.
          • 38090
          • 53 Posts
          I updated our Modx installation again today (to version 2.2.8) and the issue still happens (and the fix above still works).

          Does anyone have any insight to what could be causing this? Maybe a PHP configuration?
            • 49347
            • 7 Posts
            Place thumb.php in {core_path}/connectors/system/
            And use it with any user. May be you will add some manual checking to prevent site (D)DOS attacking.

            <?php
            // Hack for PHPThumbnail with disabled rights check
            
            define('MODX_REQP',false);
            require_once 'phpthumb.php';