summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/functions.photon.php')
-rw-r--r--plugins/jetpack/functions.photon.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/jetpack/functions.photon.php b/plugins/jetpack/functions.photon.php
index bce3b912..a75ef52b 100644
--- a/plugins/jetpack/functions.photon.php
+++ b/plugins/jetpack/functions.photon.php
@@ -12,6 +12,10 @@
function jetpack_photon_url( $image_url, $args = array(), $scheme = null ) {
$image_url = trim( $image_url );
+ if ( false !== apply_filters( 'jetpack_photon_skip_for_url', false, $image_url, $args, $scheme ) ) {
+ return $image_url;
+ }
+
$image_url = apply_filters( 'jetpack_photon_pre_image_url', $image_url, $args, $scheme );
$args = apply_filters( 'jetpack_photon_pre_args', $args, $image_url, $scheme );
@@ -62,7 +66,17 @@ function jetpack_photon_url( $image_url, $args = array(), $scheme = null ) {
$subdomain = rand( 0, 2 );
srand();
- $photon_url = "http://i{$subdomain}.wp.com/$image_host_path";
+ /**
+ * Filters the domain used by the Photon module.
+ *
+ * @since 3.4.2
+ *
+ * @param string http://i{$subdomain}.wp.com Domain used by Photon. $subdomain is a random number between 0 and 2.
+ * @param string $image_url URL of the image to be photonized.
+ */
+ $photon_domain = apply_filters( 'jetpack_photon_domain', "http://i{$subdomain}.wp.com", $image_url );
+ $photon_domain = trailingslashit( $photon_domain );
+ $photon_url = $photon_domain . $image_host_path;
// This setting is Photon Server dependent
if ( isset( $image_url_parts['query'] ) && apply_filters( 'jetpack_photon_add_query_string_to_domain', false, $image_url_parts['host'] ) ) {
@@ -158,3 +172,19 @@ function jetpack_photon_allow_facebook_graph_domain( $allow = false, $domain ) {
return $allow;
}
+
+add_filter( 'jetpack_photon_skip_for_url', 'jetpack_photon_banned_domains', 9, 4 );
+function jetpack_photon_banned_domains( $skip, $image_url, $args, $scheme ) {
+ $banned_domains = array(
+ 'http://chart.googleapis.com/',
+ 'https://chart.googleapis.com/',
+ 'http://chart.apis.google.com/',
+ );
+
+ foreach ( $banned_domains as $banned_domain ) {
+ if ( wp_startswith( $image_url, $banned_domain ) )
+ return true;
+ }
+
+ return $skip;
+}