Support » Plugin: Jetpack by WordPress.com » How to have Photon ignore more than one image?

  • Resolved ned4spd8874

    (@ned4spd8874)


    I am trying to use the code

    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 );

    to ignore certain images. However, when I try to add the line in multiple times I get an error saying “Fatal error: Cannot redeclare my_photon_exception() (previously declared in…”.

    So how can I add multiple images to be ignored?

    https://wordpress.org/plugins/jetpack/

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

    (@jeherve)

    Jetpack Mechanic 🚀

    You can add multiple images to the function like so:

    function jeherve_photon_exception( $skip, $src ) {
    	$images = array(
    		'YOUR_IMAGE_URL',
    		'YOUR_OTHER_IMAGE_URL',
    		'A_THIRD_IMAGE_URL'
    	);
    
    	if ( in_array( $src, $images ) ) {
    		return true;
    	}
    
    	return $skip;
    }
    add_filter( 'jetpack_photon_skip_image', 'jeherve_photon_exception', 10, 3 );

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to have Photon ignore more than one image?’ is closed to new replies.