• Resolved v1ao

    (@v1ao)


    Hi,

    While I really enjoy the ShortPixel’s image optimization feature within Autoptimize, however I have an issue with one PNG file (my site’s logo with transparancy) that just looks too bad optimized. I couldn’t find on my own how to prevent that particular image from being optimized, so hoping to get some help here.

    I saw this code: add_filter('autoptimize_filter_imgopt_do_css','__return_false');
    that was suggested for another problem in this support thread. Maybe something similar can work in my case? I’m also not sure where should such filter be added to?

    And big thanks for creating this plugin!

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

    (@optimizingmatters)

    There’s a filter for that indeed (a lot of those in AO to allow it to be tailored to almost any situation) 🙂

    
    add_filter('autoptimize_filter_imgopt_noptimize','exclude_images');
    function exclude_images() {
        return 'sitelogo.png, anohterimage.jpg';
    }

    The above would stop sitelogo.png and anohterimage.jpg from being optimized by Autoptimize, you can put any image filename in the comma-separated list, but also a directory name such as wp-content/uploads/transparant/ which would exclude all images in that directory.

    The best (easiest & safest) manner to add such a code snippet it using the code snippets plugin.

    hope this helps,
    frank

    Thread Starter v1ao

    (@v1ao)

    That did it! Thank you a lot for your help, Frank!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Exclude an image from ShortPixel optimization’ is closed to new replies.