Update to handle both old and new versions of Jetpack
See https://github.com/Automattic/jetpack/pull/30050/
This commit is contained in:
parent
3f4c44db05
commit
56d2b7e8be
1 changed files with 10 additions and 2 deletions
|
@ -312,15 +312,23 @@ class Post {
|
||||||
* the image strings returned will use the Photon URL.
|
* the image strings returned will use the Photon URL.
|
||||||
* We don't want that since Fediverse instances already do caching on their end.
|
* We don't want that since Fediverse instances already do caching on their end.
|
||||||
* Let the CDN only be used for visitors of the site.
|
* Let the CDN only be used for visitors of the site.
|
||||||
|
*
|
||||||
|
* Old versions of Jetpack used the Jetpack_Photon class to do this.
|
||||||
|
* New versions use the Image_CDN class.
|
||||||
|
* Let's handle both.
|
||||||
*/
|
*/
|
||||||
if ( class_exists( 'Jetpack_Photon' ) ) {
|
if ( \class_exists( '\Automattic\Jetpack\Image_CDN\Image_CDN' ) ) {
|
||||||
|
\remove_filter( 'image_downsize', array( \Automattic\Jetpack\Image_CDN\Image_CDN::instance(), 'filter_image_downsize' ) );
|
||||||
|
} elseif ( \class_exists( 'Jetpack_Photon' ) ) {
|
||||||
\remove_filter( 'image_downsize', array( \Jetpack_Photon::instance(), 'filter_image_downsize' ) );
|
\remove_filter( 'image_downsize', array( \Jetpack_Photon::instance(), 'filter_image_downsize' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumbnail = \wp_get_attachment_image_src( $id, 'full' );
|
$thumbnail = \wp_get_attachment_image_src( $id, 'full' );
|
||||||
|
|
||||||
// Re-enable Photon now that the image URL has been built.
|
// Re-enable Photon now that the image URL has been built.
|
||||||
if ( class_exists( 'Jetpack_Photon' ) ) {
|
if ( \class_exists( '\Automattic\Jetpack\Image_CDN\Image_CDN' ) ) {
|
||||||
|
\add_filter( 'image_downsize', array( \Automattic\Jetpack\Image_CDN\Image_CDN::instance(), 'filter_image_downsize' ), 10, 3 );
|
||||||
|
} elseif ( \class_exists( 'Jetpack_Photon' ) ) {
|
||||||
\add_filter( 'image_downsize', array( \Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 );
|
\add_filter( 'image_downsize', array( \Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue