• Resolved outcats85

    (@outcats85)


    Is there a way to disable the Image optimization on a per post type? I need it only on Pages and NOT on Posts.

    Thanks

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

    (@optimizingmatters)

    With a couple of lines of code hooking into the autoptimize_filter_imgopt_do filter, sure. Something like below untested example code should work;

    add_filter('autoptimize_filter_imgopt_do', 'no_imgopt_posts');
    function no_imgopt_pages() {
        if ( is_page() ) {
            return true;
        } else {
            return false;
        }
    }

    hope this helps,
    frank

    Thread Starter outcats85

    (@outcats85)

    Thanks!

    I get this error though:
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘no_imgopt_posts’ not found or invalid function name

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    arghh .. I changed the function name, but only once instead of for the 2 instances. Try this;

    add_filter('autoptimize_filter_imgopt_do', 'no_imgopt_posts');
    function no_imgopt_posts() {
        if ( is_page() ) {
            return true;
        } else {
            return false;
        }
    }
    Thread Starter outcats85

    (@outcats85)

    You’re the best! Thanks man!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome outcats85 , feel free to leave a review of the plugin and support here! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Image optimization on a per post type’ is closed to new replies.