Last active
March 1, 2016 07:30
-
-
Save jeherve/b026862701798ce5673f to your computer and use it in GitHub Desktop.
[Themify Ultra / Jetpack's Photon module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The theme appears to be using its own function, `themify_get_image()`, to build image URLs used to display images above posts. | |
* It can grab image details (like dimensions) from custom fields in each post, | |
* and then builds a custom HTML output based on parameters you can add to the function. | |
* | |
* Photon won't be able to support that, so they'll need to make these images don't get processed by Photon at all. | |
* | |
* Add the following to a functionality plugin to force Photon to ignore such images | |
*/ | |
function jetpackme_themify_stop_photon() { | |
$photon_removed = remove_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ) ); | |
} | |
add_action( 'themify_before_post_image', 'jetpackme_themify_stop_photon' ); | |
function jetpackme_themify_reenable_photon() { | |
if ( $photon_removed ) { | |
add_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 ); | |
} | |
} | |
add_action( 'themify_after_post_image', 'jetpackme_themify_reenable_photon' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment