• Resolved eclev91

    (@eclev91)


    Need: A way to programmatically skip the compression process

    If you have staging or local sites, you’re probably trying to keep databases sort of in sync. For me, I’m always pulling from upstream, and never pushing. This means all final changes to the database (new posts, image uploads, whatever) usually happen live.

    That’s the only place I want compression to happen, because otherwise I’m doubling up on my compressions if I upload something locally playing around.

    With a proper filter to skip the process, I could do something like:

    if(WP_DEBUG == true) add_filter('tinypng_compress_images', '__return_false');

    Or if you have environment detection set up or whatever one may choose.

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

    (@tinypng)

    Hi Eclev, what you can probably do is just set a wrong API key in your local environment and then the plugin will simply not optimise any images there.

    if ( $_SERVER[ 'PHP_ENV' ] == 'local' ) {
      define( 'TINY_API_KEY', 'WRONG_API_KEY' );
    }
    Thread Starter eclev91

    (@eclev91)

    Haha, that’s quite clever! I stand by putting a more WordPress-ey hook in place, but that’ll work for me for now. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter to quit?’ is closed to new replies.