Broken Thumbnails in MODX Manager for Out of Webroot Images

, written by: Novriko P. Parhusip

This situation only applies for custom Media Source above webroot.

MODX uses phpThumb to render thumbnails in the Manager side.

If MODX doesn't render image thumbnails in manager for the files that are in folder which is out of webroot, then try to check these stuffs:

  1. Set basePath of the Media Source with the absolute path to the directory (eg: /home/myaccount/mydirectory/),
  2. Set basePathRelative to "No",
  3. Leave baseUrl empty and baseUrlRelative to "Yes",
  4. Make sure the basePath value in Media Source does not have spaces before and after the path
  5. Search for "phpthumb_allow_src_above_docroot" in System Settings, and change the value to "Yes"

Debugging

phpThumb provides debug messages, but at the moment MODX doesn't have System Settings to enable it.

If you want to enable it for a temporary time, hack these files:

1. "core/model/phpthumb/phpthumb.class.php" file, at the line around 144, change

var $config_disable_debug                        = true;

to

var $config_disable_debug                        = false;

2.  "core-arsid/model/phpthumb/modphpthumb.class.php" file, change generate() method to this:


    /**
     * Generate a thumbnail
     */
    public function generate() {
        if (!$this->GenerateThumbnail()) {
            $this->modx->log(modX::LOG_LEVEL_ERROR,'phpThumb was unable to generate a thumbnail for: '.$this->cache_filename);
            $this->modx->log(modX::LOG_LEVEL_ERROR, implode("\n* ", $this->debugmessages));
            return false;
        }
        return true;
    }

Then you will get verbose debug messages in your error log.

Revert all changes back if you are done with your debugging.



Comments

blog comments powered by Disqus