PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / trunk
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance vtrunk
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | vendor/rosell-dk/webp-convert/src/Convert/Converters/Ewww.php +13 -5 3.2.3 → trunk View file →
@@ -24,9 +24,9 @@
24 24 {
25 25 use CloudConverterTrait;
26 26 use CurlTrait;
27 27
28 - /** @var array Array of invalid or exceeded api keys discovered during conversions (during the request) */
28 + /** @var array|null Array of invalid or exceeded api keys discovered during conversions (during the request) */
29 29 public static $nonFunctionalApiKeysDiscoveredDuringConversion;
30 30
31 31 public function getUniqueOptions($imageType)
32 32 {
@@ -194,9 +194,10 @@
194 194 // For example, it may return a message such as '{"error":"invalid","t":"exceeded"}
195 195 // Messages has a http content type of ie 'text/html; charset=UTF-8
196 196 // Images has application/octet-stream.
197 197 // So verify that we got an image back.
198 - if (curl_getinfo($ch, CURLINFO_CONTENT_TYPE) != 'application/octet-stream') {
198 + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
199 + if (($contentType != 'application/octet-stream') && ($contentType != 'image/webp')) {
199 200 //echo curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
200 201 curl_close($ch);
201 202
202 203 /*
@@ -225,8 +226,10 @@
225 226
226 227 throw new ConversionFailedException(
227 228 'ewww api did not return an image. It could be that the key is invalid. Response: '
228 229 . $response
230 + . ". Content type: "
231 + . curl_getinfo($ch, CURLINFO_CONTENT_TYPE)
229 232 );
230 233 }
231 234
232 235 // Not sure this can happen. So just in case
@@ -281,9 +284,10 @@
281 284 $response = curl_exec($ch);
282 285 if (curl_errno($ch)) {
283 286 return 'curl error' . curl_error($ch);
284 287 }
285 - if (curl_getinfo($ch, CURLINFO_CONTENT_TYPE) != 'application/octet-stream') {
288 + $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
289 + if (($contentType != 'application/octet-stream') && ($contentType != 'image/webp')) {
286 290 curl_close($ch);
287 291
288 292 /* May return this: {"error":"invalid","t":"exceeded"} */
289 293 $responseObj = json_decode($response);
@@ -342,12 +346,16 @@
342 346 return 'invalid';
343 347 }
344 348 $responseObj = json_decode($response);
345 349 if (isset($responseObj->error)) {
346 - if ($responseObj->error == 'invalid') {
350 + if (($responseObj->error == 'invalid') || ($responseObj->error == 'bye invalid')) {
347 351 return 'invalid';
348 352 } else {
349 - throw new \Exception('Ewww returned unexpected error: ' . $response);
353 + if ($responseObj->error == 'bye invalid') {
354 + return 'invalid';
355 + } else {
356 + throw new \Exception('Ewww returned unexpected error: ' . $response);
357 + }
350 358 }
351 359 }
352 360 if (!isset($responseObj->status)) {
353 361 throw new \Exception('Ewww returned unexpected response to verify request: ' . $response);