Skip to content

Commit

Permalink
Added filter to the get_attachment_url function.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradt committed Sep 9, 2012
1 parent e777cd4 commit bbe1aed
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions wordpress-s3/class-plugin-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
?>

0 comments on commit bbe1aed

Please sign in to comment.