• Should it still work with WP 4.5.2.?
    I noticed that the images I upload are saved as is. No reduction in size, no matter what compression level I set.

    In case you want to update your plugin. This is how I do it (note: this code produces sometimes some text output which it of course should not…):

    function filter_wp_handle_upload($array, $var)
    {
        $name  = $array["file"];
        $image = wp_get_image_editor($name);
        if (!is_wp_error($image)) {
            $temp = $image->generate_filename();
            $image->set_quality(75);
            $saved = $image->save($temp);
            if (file_exists($temp)) {
                if (filesize($temp) < filesize($name)) {
                    rename($temp, $name);
                }
        	} else {
         	   unlink($temp);
        	}
    	}
        return $array;
    }
    ;
    
    // add the filter
    add_filter('wp_handle_upload', 'filter_wp_handle_upload', 10, 2);

    https://www.ads-software.com/plugins/jpg-image-qualitycompression/

  • The topic ‘No effect with WP 4.5.2’ is closed to new replies.