Skip to content

Commit bbe1aed

Browse files
committed
Added filter to the get_attachment_url function.
1 parent e777cd4 commit bbe1aed

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

wordpress-s3/class-plugin-public.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ function wp_get_attachment_url($url, $postID) {
1919
if (!$this->options) $this->options = get_option('tantan_wordpress_s3');
2020

2121
if ($this->options['wp-uploads'] && ($amazon = get_post_meta($postID, 'amazonS3_info', true))) {
22-
$accessDomain = ($this->options['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $amazon['bucket'] : $amazon['bucket'].'.s3.amazonaws.com'));
23-
return 'http://'.$accessDomain.'/'.$amazon['key'];
24-
} else {
25-
return $url;
26-
}
22+
if ( isset($this->options['cloudfront']) && $this->options['cloudfront'] ) {
23+
$accessDomain = $this->options['cloudfront'];
24+
}
25+
elseif ( isset($this->options['virtual-host']) && $this->options['virtual-host'] ) {
26+
$accessDomain = $this->options['bucket'];
27+
}
28+
else {
29+
$accessDomain = $amazon['bucket'] . '.s3.amazonaws.com';
30+
}
31+
32+
$url = 'https://'.$accessDomain.'/'.$amazon['key'];
33+
34+
$url = apply_filters( 'wps3_get_attachment_url', $url, $postID, $this );
35+
}
36+
37+
return $url;
2738
}
2839
}
29-
?>

0 commit comments

Comments
 (0)