WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] Tell photon to ignore an image? (3 posts)

  1. mickmel
    Member
    Posted 1 year ago #

    Photon is working great, but I have one image that I'd like for it to ignore. It's a feed from a web cam, so the image is updated every few minutes. However, photon doesn't update the cache (as is proper), so the image on the site doesn't update. The only solution I can see is to disable photon site-wide, which isn't desireable.

    Is there a way to have it ignore that one image? Maybe a tag at the end like "image.jpg?photon=no" or something?

    http://wordpress.org/extend/plugins/jetpack/

  2. designsimply
    Member
    Plugin Contributor

    Posted 1 year ago #

    The Jetpack developers just made an update to allow this. You'll see it working in the next Jetpack release, or you can apply the following patch if you don't want to wait:
    https://plugins.trac.wordpress.org/changeset/632052

    After the patch is applied, you would need to add a hook. Here is a super basic example:

    function my_photon_exception( $skip, $src ) {
            if ( $src == 'YOUR_IMAGE_URL' ) {
                    return true;
            }
            return $skip;
    }
    add_filter( 'jetpack_photon_skip_image', 'my_photon_exception', 10, 3 );

    Replace YOUR_IMAGE_URL with the URL of the image you want to skip.

  3. Ry L
    Member
    Posted 1 year ago #

    Hey I know that Photon admits that GIFs don't work well with re-sizing, so I found this thread in my search for excluding them from Photon.

    I'm trying to learn PHP as I go, and I'm in need of some help/clarification.

    my condition is:

    if ( strpos( $src, '.gif' ) !== false  )

    but the main thing I'm confused on is how to make ANY post images/attachments go through this function so that any GIF is not put through photon (since it doesn't work anyways)

    also, I found somehthing about:

    $allowed_types = apply_filters( 'allowed_types', array(
    	        'gif',
    	        'jpg',
    	        'jpeg',
    	        'png',
    	) );

    when i was looking around...is it possible (or even easier) to just change the allowed types?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic