The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

WP Smush - Image Optimization
[resolved] [Plugin: WP Smush.it] Fix for timeouts after 5000 milliseconds (6 posts)

  1. Milan Dinić
    Posted 6 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);.


  2. Derek Perkins
    Posted 6 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ć
    Posted 6 years ago #

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

  4. Tosh
    Posted 6 years ago #

    That worked! Thank you dimadin!

  5. Alex Dunae
    Plugin Contributor

    Posted 5 years ago #

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

  6. Moogle Stiltzkin
    Posted 5 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

  • WP Smush - Image Optimization
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic