diff --git a/wordpress-s3/class-plugin-public.php b/wordpress-s3/class-plugin-public.php index bc98128e..e42936e5 100644 --- a/wordpress-s3/class-plugin-public.php +++ b/wordpress-s3/class-plugin-public.php @@ -19,11 +19,21 @@ 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['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $amazon['bucket'] : $amazon['bucket'].'.s3.amazonaws.com')); - return 'http://'.$accessDomain.'/'.$amazon['key']; - } else { - return $url; - } + if ( isset($this->options['cloudfront']) && $this->options['cloudfront'] ) { + $accessDomain = $this->options['cloudfront']; + } + elseif ( isset($this->options['virtual-host']) && $this->options['virtual-host'] ) { + $accessDomain = $this->options['bucket']; + } + else { + $accessDomain = $amazon['bucket'] . '.s3.amazonaws.com'; + } + + $url = 'https://'.$accessDomain.'/'.$amazon['key']; + + $url = apply_filters( 'wps3_get_attachment_url', $url, $postID, $this ); + } + + return $url; } } -?> \ No newline at end of file