phpThumbOf is a secure, custom Output Filter for MODx Revolution that allows you to use phpThumb on any image URL specified in a placeholder.
- MODx Revolution 2.0.4 or later
- PHP5 or later
phpThumbOf was written by Shaun McCormick as a secure phpThumb output filter, and first released on November 3rd, 2010.
- w = Width (in pixels)
- h = Height (in pixels)
- zc = Zoom Cropping. Set to 1 to enable zoom cropping.
Transform an image to 120px by 120px.
Make a 300x300 size thumbnail, with zoom cropping.
|If using a TV, the Output Type for the TV must be 'text'.|
The above properties are not the only ones you can use with phpthumbof. You can find more documentation on phpThumb using Google or in the readme (all properties are about 1/3rds down).
Taking it Further
phpThumbOf can use Amazon S3 to store cached images instead of storing them locally. You can also use the Amazon CloudFront content delivery network to serve these images. You will first need to create an account with Amazon AWS and create an Amazon S3 bucket to use with phpThumbOf. To use CloudFront, create a CloudFront distribution to use with this bucket, and set up a domain alias if you wish to use one.
Use the following system settings to configure phpThumbOf to use Amazon S3. These settings can be overridden by calling phpThumbOf as a snippet and specifying different settings in the snippet call, or by using a property set.
|System Setting Name||Key||Description|
|Amazon S3 Bucket||phpthumbof.s3_bucket||The name of the Amazon S3 bucket you wish to use with phpThumbOf.|
|Amazon S3 Cache Time||phpthumbof.s3_cache_time||The number of hours to cache a thumbnail for on Amazon S3. Thumbnails older than this will be automatically regenerated when phpThumbOf is called uncached. If the phpThumbOfCacheManager plugin is enabled, it will clear all thumbnails on Amazon S3 when the site cache is cleared.|
|Use PHP get_headers to Check Modified Date||phpthumbof.s3_headers_check||If set to "Yes" phpThumbOf will use PHP's get_headers to check the modified date on S3 thumbos. By default this is set to "No" meaning phpThumbOf will use Amazon S3 get_object_url, which is faster. Turn this on if you are experiencing caching issues.|
|Amazon S3 Host Alias||phpthumbof.s3_host_alias||If you are using a CNAME or other alias to change the domain of the S3 service, enter it here (with no trailing slash). If you are using Amazon CloudFront for content delivery, enter the domain you are using for CloudFront delivery. This could be the domain of your CloudFront distribution, or a domain you are using as an alias for that distribution.|
|Amazon S3 Key||phpthumbof.s3_key||Set this to the Access Key ID of your Amazon S3 account, which you can find on the Security Credentials page of your Amazon S3 account.|
|Amazon S3 Bucket Path||phpthumbof.s3_path||The path in your Amazon S3 bucket where you want the phpThumbOf cache files to go.|
|Amazon S3 Secret Key||phpthumbof.s3_secret_key||Set this to the Secret Access Key of your Amazon S3 account, found on the Security Credentials page|
|Use Amazon S3||phpthumbof.use_s3||Once you have configured all of the above settings, set this to "Yes" to use your Amazon S3 bucket to store cached thumbnails.|
Unless storage space is a problem or you are using many different dynamically-generated thumbnails, you may wish to disable the phpThumbOfCacheManager plugin when using Amazon S3 to improve performance. After the site cache is cleared or when phpThumbOf is called uncached, phpThumbOf will check whether the thumbnail already exists on AmazonS3 before regenerating it. phpThumbOf will still regenerate the cached thumbnail when called uncached and the thumbnail is older than the number of hours specified in the Amazon S3 Cache Time setting.
- Make sure that the "assets/components/phpthumbof/cache" directory is created and is writable by PHP
- Make sure you have ImageMagick installed and enabled on your PHP installation
- If your host is using symlinks for its directory structure, make sure they point to the correct, true path in core/config/config.inc.php