Skip to content

Commit bc2c345

Browse files
author
Jippe Holwerda
committed
Fixed compressing images using fopen.
1 parent 0d38696 commit bc2c345

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/class-tiny-compress-fopen.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ protected function shrink_options($input) {
2828
'Authorization: Basic ' . base64_encode('api:' . $this->api_key),
2929
'User-Agent: ' . Tiny_WP_Base::plugin_identification() . ' fopen',
3030
),
31-
'content' => $input
31+
'content' => $input,
32+
'follow_location' => 0,
33+
'max_redirects' => 1, // Necessary for PHP 5.2
34+
'ignore_errors' => TRUE // Apparently, a 201 is a failure :'(
3235
),
3336
'ssl' => array(
3437
'cafile' => self::get_ca_file(),

src/class-tiny-compress.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ protected static function decode($text) {
115115
$result = json_decode($text, true);
116116
if ($result === null) {
117117
throw new Tiny_Exception(sprintf('JSON: %s [%d]',
118-
PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Error',
119-
json_last_error()),
118+
PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error',
119+
PHP_VERSION_ID >= 50300 ? json_last_error() : 'Error'),
120120
'JsonError');
121121
}
122122
return $result;

0 commit comments

Comments
 (0)