Permalink
Browse files

Merging Amazon CloudFront feature from the plugin by James Low.

  • Loading branch information...
1 parent ddaf8b5 commit 3151c9f6287f5acbcd19493e6f0bb5af14db64cd @bradt bradt committed Sep 4, 2012
@@ -182,6 +182,12 @@ <h2 id="write-post">Amazon S3 Plugin for WordPress</h2>
</td>
</tr>
+ <tr valign="top">
+ <th width="33%" scope="row">Cloud Front:</th>
+ <td>
+ <input type="text" name="options[cloudfront]" value="<?php echo $options['cloudfront']; ?>" size="50" /><br />
+ </td>
+ </tr>
<tr valign="top">
<th width="33%" scope="row">&nbsp;</th>
@@ -19,7 +19,7 @@ function wp_get_attachment_url($url, $postID) {
if (!$this->options) $this->options = get_option('tantan_wordpress_s3');
if ($this->options['wp-uploads'] && ($amazon = get_post_meta($postID, 'amazonS3_info', true))) {
- $accessDomain = $this->options['virtual-host'] ? $amazon['bucket'] : $amazon['bucket'].'.s3.amazonaws.com';
+ $accessDomain = ($this->options['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $amazon['bucket'] : $amazon['bucket'].'.s3.amazonaws.com'));
return 'http://'.$accessDomain.'/'.$amazon['key'];
} else {
return $url;
@@ -55,7 +55,7 @@ function addhooks() {
if (!$_POST['disable_amazonS3']) {
add_filter('wp_update_attachment_metadata', array(&$this, 'wp_update_attachment_metadata'), 9, 2);
//can't delete mirrored files just yet
- //add_filter('wp_get_attachment_metadata', array(&$this, 'wp_get_attachment_metadata'));
+ add_filter('wp_get_attachment_metadata', array(&$this, 'wp_get_attachment_metadata'));
//add_filter('wp_delete_file', array(&$this, 'wp_delete_file'));
}
}
@@ -149,7 +149,7 @@ function wp_delete_file($file) {
if (deleteObject($this->meta['bucket'], $this->meta['key'])) {
}
- $accessDomain = $this->options['virtual-host'] ? $this->meta['bucket'] : $this->meta['bucket'].'.s3.amazonaws.com';
+ $accessDomain = ($this->options['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $this->meta['bucket'] : $this->meta['bucket'].'.s3.amazonaws.com'));
return $file;
//return 'http://'.$accessDomain.'/'.$amazon['key'];
@@ -319,7 +319,7 @@ function upload_tabs_scripts() {
//wp_enqueue_script('prototype');
if (!$this->options) $this->options = get_option('tantan_wordpress_s3');
- $accessDomain = $this->options['virtual-host'] ? $this->options['bucket'] : $this->options['bucket'].'.s3.amazonaws.com';
+ $accessDomain = ($this->options['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $this->options['bucket'] : $this->options['bucket'].'.s3.amazonaws.com'));
include(dirname(__FILE__).'/admin-tab-head.html');
}
@@ -363,7 +363,7 @@ function tab() {
return;
}
$bucket = $this->options['bucket'];
- $accessDomain = $this->options['virtual-host'] ? $this->options['bucket'] : $this->options['bucket'].'.s3.amazonaws.com';
+ $accessDomain = ($this->options['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $this->options['bucket'] : $this->options['bucket'].'.s3.amazonaws.com'));
$prefix = $_GET['prefix'] ? $_GET['prefix'] : '';
list($prefixes, $keys, $meta, $privateKeys) = $this->getKeys($restrictPrefix.$prefix);
@@ -16,5 +16,6 @@
'permissions' => '', // set to "public" to have the plugin force all files in the specified bucket to "public" (sometimes third party upload utilities don't do this)
'hideAmazonS3UploadTab' => false, // hide the Amazon S3 tab in the WordPress upload widget
'expires' => 315360000, // set http expires header 10 years into the future
+ 'cloudfront' => '', //this can be your cloudfront DNS name (*.cloudfront.net) or a CNAME alias
);
?>

0 comments on commit 3151c9f

Please sign in to comment.