WordPress.org

Plugin Directory

Changeset 682155


Ignore:
Timestamp:
03/15/13 05:45:40 (13 months ago)
Author:
alexdunae
Message:

attempt to smush more than one image before bailing

Location:
wp-smushit/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-smushit/trunk/readme.txt

    r680988 r682155  
    6161 
    6262== Changelog == 
     63 
     64= 1.6.3 = 
     65* attempt to smush more than one image before bailing (kind thanks to <a href="http://wordpress.org/support/profile/xrampage16">xrampage16</a>) 
    6366 
    6467= 1.6.2 = 
  • wp-smushit/trunk/wp-smushit.php

    r680986 r682155  
    6363  @ini_set('zlib.output_compression', 0); 
    6464  @ini_set('implicit_flush', 1); 
    65    
     65 
    6666  $attachments = null; 
    6767  $auto_start = false; 
    68    
     68 
    6969  if ( isset($_REQUEST['ids'])) { 
    7070    $attachments = get_posts( array( 
     
    8282    )); 
    8383  } 
    84    
     84 
    8585 
    8686  require( dirname(__FILE__) . '/bulk.php' ); 
     
    127127 
    128128    // canonicalize path - disabled 2011-02-1 troubleshooting 'Could not find...' errors. 
    129     // From the PHP docs: "The running script must have executable permissions on  
     129    // From the PHP docs: "The running script must have executable permissions on 
    130130    // all directories in the hierarchy, otherwise realpath() will return FALSE." 
    131131    // $file_path = realpath($file); 
    132      
     132 
    133133    $file_path = $file; 
    134134    // check that the file exists 
     
    221221    return TRUE; 
    222222  } 
    223    
     223 
    224224  if ( stripos($previous_status, 'no savings') !== FALSE || stripos($previous_status, 'reduced') !== FALSE ) { 
    225225    return FALSE; 
     
    294294 
    295295    $data = false; 
    296      
     296 
    297297    if ( function_exists('wp_remote_get') ) { 
    298         $response = wp_remote_get($req, array('user-agent' => WP_SMUSHIT_UA, 'timeout' => 20)); 
    299  
    300         if( is_wp_error( $response ) ) { 
    301           wp_smushit_temporarily_disable(); 
    302           $msg = 'Automatic smushing has been disabled temporarily due to an error. ' . $response->get_error_message(); 
    303             wp_die( $msg ); 
    304         } 
    305  
    306         $data = wp_remote_retrieve_body($response); 
     298    $count = 0; 
     299    $finished = FALSE; 
     300    do { 
     301      $response = wp_remote_get($req, array('user-agent' => WP_SMUSHIT_UA, 'timeout' => 20)); 
     302      if ( is_wp_error( $response ) ) { 
     303        $count++; 
     304      } else { 
     305        $finished = TRUE; 
     306      } 
     307      if ($count == 3) { 
     308        //$msg = 'Automatic smushing has been disabled temporarily due to an error. ' . $response->get_error_message() .' - url | '. $file_url; 
     309        //wp_die( $msg ); 
     310        $response = FALSE; 
     311        $finished = TRUE; 
     312      } 
     313    } while (!$finished); 
     314 
     315    if ( !$response ) { 
     316      $data = FALSE; 
     317    } else { 
     318      $data = wp_remote_retrieve_body($response); 
     319    } 
    307320    } else { 
    308321        wp_die( __('WP Smush.it requires WordPress 2.8 or greater', WP_SMUSHIT_DOMAIN) ); 
    309322    } 
    310      
     323 
    311324    return $data; 
    312325} 
Note: See TracChangeset for help on using the changeset viewer.