splittingred/phpThumbOf — Issue #26: Unable to specify URL when using custom cache path w/ subdomains
Author: Mark-H
Created: 2011-10-16 13:03:13+00:00
State: open

I've got a MODX setup where I need to use subdomains for different subsites, and am using phpthumbof there. Using the out-of-the-box settings doesn't work, as it tries to find the assets/components/.. directory on the subdomain and *not* the main domain where MODX is installed on.

I changed the cache path setting of phpthumbof to my non-MODX assets directory, web accessible at assets.site.com to keep all assets on there. All good, but there isn't a cache_url parameter to point it there, so diving into the snippet I found that it's building the cache url from the assets_url setting.

Setting that to http://assets.site.com/thumbs/ (the link I want to use) however doesn't work cause of the last line here:

$assetsUrl = $modx->getOption('phpthumbof.assets_url',$scriptProperties,$modx->getOption('assets_url').'components/phpthumbof/');
$cacheUrl = $assetsUrl.'cache/'.str_replace($cacheDir,'',$cacheKey);
$cacheUrl = str_replace('//','/',$cacheUrl);

I managed to get this working by commenting out this line, and setting the settings:
- cache_path: <..>/public_html/assets/thumbs/cache/
- assets_url: http://assets.site.com/assets/thumbs/

Having this working now, I think this would be easier to do next time with a cache_url setting that is taken as-is (and doesn't get /cache/ appended like the assets_url). In that case, I would've been able to set an absolute cache_url setting (eg http://site.com/assets/components/phpthumbof/cache/) and use that to customize where the images are being loaded from.

An other option would be a setting for making the phpthumbof snippet returning an absolute URL.