Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion _build/data/transport.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,21 @@ function stripPhpTags($filename) {
'area' => 'Amazon S3',
), '', true, true);

return $systemSettings;
$systemSettings[$ssIdx] = $modx->newObject('modSystemSetting');
$systemSettings[$ssIdx++]->fromArray(array (
'key' => 'pthumb.s3_output_cloudfront',
'value' => FALSE,
'xtype' => 'combo-boolean',
'namespace' => 'phpthumbof',
'area' => 'Amazon S3',
), '', true, true);

$systemSettings[$ssIdx] = $modx->newObject('modSystemSetting');
$systemSettings[$ssIdx++]->fromArray(array (
'key' => 'pthumb.s3_output_cloudfront_url',
'xtype' => 'textfield',
'namespace' => 'phpthumbof',
'area' => 'Amazon S3',
), '', true, true);

return $systemSettings;
8 changes: 7 additions & 1 deletion core/components/phpthumbof/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,11 @@
$_lang['setting_pthumb.s3_cache_path'] = 'S3 Cache Path Prefix';
$_lang['setting_pthumb.s3_cache_path_desc'] = 'A subdirectory where all cached images will be stored in the S3 bucket(s).';

$_lang['setting_pthumb.s3_output_cloudfront'] = 'S3 Output Via CloudFront';
$_lang['setting_pthumb.s3_output_cloudfront_desc'] = 'Serve thumbnails via Amazon CloudFront instead of S3 bucket when using an S3 media source for output. Please also specify the CloudFront URL.';

$_lang['prop_pthumb.debug_desc'] = 'Write debug messages to the MODX error log.';
$_lang['setting_pthumb.s3_output_cloudfront_url'] = 'CloudFront URL';
$_lang['setting_pthumb.s3_output_cloudfront__url_desc'] = 'The CloudFront URL used for serving the thumbnails. Ex: http://d111111abcdef8.cloudfront.net/';


$_lang['prop_pthumb.debug_desc'] = 'Write debug messages to the MODX error log.';
7 changes: 6 additions & 1 deletion core/components/phpthumbof/model/phpthumbof.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ function __construct(modX &$modx, &$settings_cache, $options, $s3info = 0) {
else { // initialize MS
$this->config["{$this->config['s3outKey']}_ok"] = true;
$s3properties = $s3obj->getPropertyList();
$this->config["{$this->config['s3outKey']}_url"] = $s3properties['url'];
$useCloudFront = $modx->getOption('pthumb.s3_output_cloudfront', null, false);
if ($useCloudFront) {
$this->config["{$this->config['s3outKey']}_url"] = $modx->getOption('pthumb.s3_output_cloudfront_url', null, $s3properties['url'], true); // fall-back to regular S3 url if CloudFront url is not set
} else {
$this->config["{$this->config['s3outKey']}_url"] = $s3properties['url'];
}
$s3obj->bucket = $s3properties['bucket'];
include_once MODX_CORE_PATH . 'model/aws/sdk.class.php';
define('AWS_KEY', $s3properties['key']);
Expand Down