WordPress.org

Ready to get started?Download WordPress

Forums

WP Smush.it
[resolved] Fix for timeouts after 5000 milliseconds (6 posts)

  1. Milan Dinić
    Member
    Posted 4 years ago #

    If you smush large image (eg. over 900KB), you can get error "Operation timed out after 5000 milliseconds with 0 bytes received". Problem is that WordPress by default timeouts after 5 seconds while doing HTTP requests.

    To fix this issue we need to simply add filter which increases timeout period.

    First we need function:

    function wp_smushit_filter_timeout_time($time) {
    	$time = 25; //new number of seconds
    	return $time;
    }

    Then we need to call this function via add_filter. I added this in function wp_smushit_post below $data = false; so that this filter is used only in WP smush.it:
    add_filter( 'http_request_timeout', 'wp_smushit_filter_timeout_time');

    Another thing to consider would be adding of function set_time_limit which would increase time script runs. It can be added above $data = wp_smushit_post($file_url);.

    http://wordpress.org/extend/plugins/wp-smushit/

  2. Derek Perkins
    Member
    Posted 3 years ago #

    That worked great. Thanks!

    Have you thought about adopting WP Smush.it or creating a fork that will include these updates that you're making? It appears like the original author has abandoned it.

  3. Milan Dinić
    Member
    Posted 3 years ago #

    No, I hope that Alex will update plugin with those fixes. Maybe he just doesn't have time now.

  4. Tosh
    Member
    Posted 3 years ago #

    That worked! Thank you dimadin!

  5. Alex Dunae
    Member
    Plugin Contributor

    Posted 3 years ago #

    Thanks Milan -- your fix will be in the update released today.

  6. Moogle Stiltzkin
    Member
    Posted 3 years ago #

    Pressing the Smush.it button in media library returns the

    Operation timed out after 25000 milliseconds with 0 bytes received

    Using Smush.It Version 1.3.5

    with wordpress 3.2

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags