• Resolved alpha1beta

    (@alpha1beta)


    Jetpack Photon automatically scales images and does not return the height and width of the image.

    I have several sites, where our goal is, to have large, impressive images. If for some reason, the featured image is not available in high quality, full width, (lets say 640px wide), we don’t want to provide a “near hit” at full resolution, say 620px, but rather a smaller thumbnail (320max) and style the post different (Image inline with content, floating, rather than above it).

    We have managed to do this while Jetpack is disabled, but when Jetpack is enabled, its filters prevent us from being able to get the width and height.

    What I’m looking to do it to place a wrapper around any functions, like
    image_downsize and get_post_thumbnail_id, to ignore ALL jetpack filters.

    $image_array = skip_jetpack(image_downsize($thumb_id, $size));
    or
    $image_array = skip_jetpack(“image_downsize”);

    If there any good way, of turning off jetpack’s filters for a small section of code only, I have tried removing filters, but since Jetpack uses non-statically called methods, it seems impossible to do without create a new jetpack instance. Could this be done by extending The Photon Class? or any other way?

    https://www.ads-software.com/plugins/jetpack/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    If you don’t want to use Photon at all, you could deactivate the module altogether, by following the instructions here:
    https://jetpack.me/support/activate-and-deactivate-modules/

    If you do wish to use Photon, but not for all the images, you could build your own function using the jetpack_photon_skip_image to disable Photon in some specific cases.

    You can find an example here:
    https://jetpack.me/2013/05/03/skip-a-image-with-photon/

    Let me know if it helps.

    Thread Starter alpha1beta

    (@alpha1beta)

    I managed to solve the problem, upon further inspection of photon, I found a filter and pulled this..

    add_filter('jetpack_photon_override_image_downsize', 'remove_jetpack_image_downsize');
    $imgsize = image_downsize($thumbnail_id, $as);
    remove_filter('jetpack_photon_override_image_downsize', 'remove_jetpack_image_downsize');

    with the following function to support it.

    function remove_jetpack_image_downsize(){
    return true;
    }

    For the result of, it uses the local file to fetch the image sizes, and then uses jetpack for hosting of the image. This lets us now change the layout based on the image size, while still using Photon’s CDN for hosting.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Looking to Override Jetpack Photon’ is closed to new replies.