summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
committerAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
commita6b006c0f1ef757f23375f7906193370337d8bd7 (patch)
tree4467c6423b2c54e6ef8c3e79241a833fb17833a5 /plugins/jetpack/functions.photon.php
parentUpdate akismet 4.0.7 (diff)
downloadblogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.gz
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.bz2
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.zip
Update jetpack 6.2
Diffstat (limited to 'plugins/jetpack/functions.photon.php')
-rw-r--r--plugins/jetpack/functions.photon.php45
1 files changed, 18 insertions, 27 deletions
diff --git a/plugins/jetpack/functions.photon.php b/plugins/jetpack/functions.photon.php
index de785e59..3090e5da 100644
--- a/plugins/jetpack/functions.photon.php
+++ b/plugins/jetpack/functions.photon.php
@@ -12,16 +12,16 @@
function jetpack_photon_url( $image_url, $args = array(), $scheme = null ) {
$image_url = trim( $image_url );
- if ( class_exists( 'Jetpack') ) {
+ if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) {
/**
* Disables Photon URL processing for local development
- *
- * @module photon
- *
- * @since 4.1.0
- *
- * @param bool false Result of Jetpack::is_development_mode.
- */
+ *
+ * @module photon
+ *
+ * @since 4.1.0
+ *
+ * @param bool false Result of Jetpack::is_development_mode.
+ */
if ( true === apply_filters( 'jetpack_photon_development_mode', Jetpack::is_development_mode() ) ) {
return $image_url;
}
@@ -90,23 +90,14 @@ function jetpack_photon_url( $image_url, $args = array(), $scheme = null ) {
$args = rawurlencode_deep( $args );
}
- /* Don't photon-ize WPCOM hosted images with only the following url args:
- * `w`, `h`, `fit`, `crop`, `zoom`, `strip`, `resize`, `quality`
- * These args can just be added to the wpcom-version of the image, and save on latency.
- */
- $is_wpcom_image_with_safe_args = false;
- $allowed_wpcom_keys = array(
- 'w' => true,
- 'h' => true,
- 'fit' => true,
- 'crop' => true,
- 'zoom' => true,
- 'strip' => true,
- 'resize' => true,
- 'quality' => true,
- );
- if ( wp_endswith( strtolower( $image_url_parts['host'] ), '.files.wordpress.com' ) && ! array_diff_key( $args, $allowed_wpcom_keys ) ) {
- $is_wpcom_image_with_safe_args = true;
+ // Don't photon-ize WPCOM hosted images -- we can serve them up from wpcom directly.
+ $is_wpcom_image = false;
+ if ( wp_endswith( strtolower( $image_url_parts['host'] ), '.files.wordpress.com' ) ) {
+ $is_wpcom_image = true;
+ if ( isset( $args['ssl'] ) ) {
+ // Do not send the ssl argument to prevent caching issues
+ unset( $args['ssl'] );
+ }
}
/** This filter is documented below. */
@@ -115,11 +106,11 @@ function jetpack_photon_url( $image_url, $args = array(), $scheme = null ) {
// You can't run a Photon URL through Photon again because query strings are stripped.
// So if the image is already a Photon URL, append the new arguments to the existing URL.
- // Alternately, if it's a *.files.wordpress.com url, and the arguments are supported, keep the domain.
+ // Alternately, if it's a *.files.wordpress.com url, then keep the domain as is.
if (
in_array( $image_url_parts['host'], array( 'i0.wp.com', 'i1.wp.com', 'i2.wp.com' ) )
|| $image_url_parts['host'] === jetpack_photon_parse_url( $custom_photon_url, PHP_URL_HOST )
- || $is_wpcom_image_with_safe_args
+ || $is_wpcom_image
) {
$photon_url = add_query_arg( $args, $image_url );
return jetpack_photon_url_scheme( $photon_url, $scheme );