Converter for Media – Optimize images | Convert WebP & AVIF - Version 2.4.0

Version Description

(2021-02-28) = * [Fixed] Error detection of redirects without .png as supported file extension * [Fixed] Pass Thru loading mode for servers not supporting getallheaders() function * [Changed] Level of error for cached redirects of images to WebP files * [Added] Skip re-converting images that were larger than original after converting to WebP

Download this release

Release Info

Developer mateuszgbiorczyk
Plugin Icon 128x128 Converter for Media – Optimize images | Convert WebP & AVIF
Version 2.4.0
Comparing to
See all releases

Code changes from version 2.3.0 to 2.4.0

app/Action/Convert.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace WebpConverter\Action;
4
 
5
- use WebpConverter\Method\MethodIntegrator;
6
  use WebpConverter\Media\Attachment;
 
7
 
8
  class Convert
9
  {
2
 
3
  namespace WebpConverter\Action;
4
 
 
5
  use WebpConverter\Media\Attachment;
6
+ use WebpConverter\Method\MethodIntegrator;
7
 
8
  class Convert
9
  {
app/Action/Delete.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Action;
4
 
5
  use WebpConverter\Convert\Directory;
 
6
 
7
  class Delete
8
  {
@@ -24,9 +25,14 @@
24
 
25
  private function deleteFileByPath($path)
26
  {
27
- $source = Directory::getPath($path);
28
- if (is_writable($source) && (pathinfo($source, PATHINFO_EXTENSION) === 'webp')) {
29
- unlink($source);
 
 
 
 
 
30
  }
31
  }
32
  }
3
  namespace WebpConverter\Action;
4
 
5
  use WebpConverter\Convert\Directory;
6
+ use WebpConverter\Convert\Size;
7
 
8
  class Delete
9
  {
25
 
26
  private function deleteFileByPath($path)
27
  {
28
+ if (!($sourceWebP = Directory::getPath($path))) {
29
+ return;
30
+ }
31
+
32
+ if (is_writable($sourceWebP)) {
33
+ unlink($sourceWebP);
34
+ } else if (is_writable($sourceWebP . SIZE::DELETED_FILE_EXTENSION)) {
35
+ unlink($sourceWebP . SIZE::DELETED_FILE_EXTENSION);
36
  }
37
  }
38
  }
app/Convert/Size.php CHANGED
@@ -4,6 +4,8 @@
4
 
5
  class Size
6
  {
 
 
7
  public function __construct()
8
  {
9
  add_action('webpc_convert_after', [$this, 'removeImageIfIsLarger'], 10, 2);
@@ -20,7 +22,10 @@
20
  || (!file_exists($webpPath) || !file_exists($originalPath))
21
  || (filesize($webpPath) < filesize($originalPath))) return;
22
 
 
 
23
  unlink($webpPath);
 
24
  $e = new \Exception(sprintf(
25
  'Image "%s" converted to WebP is larger than original and has been deleted.',
26
  $originalPath
4
 
5
  class Size
6
  {
7
+ const DELETED_FILE_EXTENSION = '.deleted';
8
+
9
  public function __construct()
10
  {
11
  add_action('webpc_convert_after', [$this, 'removeImageIfIsLarger'], 10, 2);
22
  || (!file_exists($webpPath) || !file_exists($originalPath))
23
  || (filesize($webpPath) < filesize($originalPath))) return;
24
 
25
+ $file = fopen($webpPath . self::DELETED_FILE_EXTENSION, 'w');
26
+ fclose($file);
27
  unlink($webpPath);
28
+
29
  $e = new \Exception(sprintf(
30
  'Image "%s" converted to WebP is larger than original and has been deleted.',
31
  $originalPath
app/Error/RewritesError.php CHANGED
@@ -4,9 +4,9 @@
4
 
5
  use WebpConverter\Error\ErrorAbstract;
6
  use WebpConverter\Error\ErrorInterface;
7
- use WebpConverter\Traits\FileLoaderTrait;
8
  use WebpConverter\Convert\Directory;
9
  use WebpConverter\Loader\LoaderAbstract;
 
10
 
11
  class RewritesError extends ErrorAbstract implements ErrorInterface
12
  {
@@ -28,6 +28,9 @@
28
  $this->convertImagesForDebug();
29
  $errors = [];
30
 
 
 
 
31
  if ($this->ifRedirectsAreWorks() !== true) {
32
  if ($this->ifBypassingApacheIsActive() === true) {
33
  $errors[] = 'bypassing_apache';
@@ -38,6 +41,9 @@
38
  $errors[] = 'rewrites_cached';
39
  }
40
 
 
 
 
41
  return $errors;
42
  }
43
 
@@ -78,15 +84,9 @@
78
  {
79
  $uploadsUrl = apply_filters('webpc_dir_url', '', 'uploads');
80
 
81
- add_filter('webpc_get_values', ['WebpConverter\Settings\Errors', 'setExtensionsForDebug']);
82
- do_action(LoaderAbstract::ACTION_NAME, true);
83
-
84
  $filePng = $this->getFileSizeByUrl($uploadsUrl . self::PATH_OUTPUT_FILE_PNG);
85
  $filePng2 = $this->getFileSizeByUrl($uploadsUrl . self::PATH_OUTPUT_FILE_PNG2);
86
 
87
- remove_filter('webpc_get_values', ['WebpConverter\Settings\Errors', 'setExtensionsForDebug']);
88
- do_action(LoaderAbstract::ACTION_NAME, true);
89
-
90
  return ($filePng > $filePng2);
91
  }
92
 
4
 
5
  use WebpConverter\Error\ErrorAbstract;
6
  use WebpConverter\Error\ErrorInterface;
 
7
  use WebpConverter\Convert\Directory;
8
  use WebpConverter\Loader\LoaderAbstract;
9
+ use WebpConverter\Traits\FileLoaderTrait;
10
 
11
  class RewritesError extends ErrorAbstract implements ErrorInterface
12
  {
28
  $this->convertImagesForDebug();
29
  $errors = [];
30
 
31
+ add_filter('webpc_get_values', ['WebpConverter\Settings\Errors', 'setExtensionsForDebug']);
32
+ do_action(LoaderAbstract::ACTION_NAME, true);
33
+
34
  if ($this->ifRedirectsAreWorks() !== true) {
35
  if ($this->ifBypassingApacheIsActive() === true) {
36
  $errors[] = 'bypassing_apache';
41
  $errors[] = 'rewrites_cached';
42
  }
43
 
44
+ remove_filter('webpc_get_values', ['WebpConverter\Settings\Errors', 'setExtensionsForDebug']);
45
+ do_action(LoaderAbstract::ACTION_NAME, true);
46
+
47
  return $errors;
48
  }
49
 
84
  {
85
  $uploadsUrl = apply_filters('webpc_dir_url', '', 'uploads');
86
 
 
 
 
87
  $filePng = $this->getFileSizeByUrl($uploadsUrl . self::PATH_OUTPUT_FILE_PNG);
88
  $filePng2 = $this->getFileSizeByUrl($uploadsUrl . self::PATH_OUTPUT_FILE_PNG2);
89
 
 
 
 
90
  return ($filePng > $filePng2);
91
  }
92
 
app/Loader/LoaderAbstract.php CHANGED
@@ -3,7 +3,6 @@
3
  namespace WebpConverter\Loader;
4
 
5
  use WebpConverter\Loader\LoaderInterface;
6
- use WebpConverter\Settings\Errors;
7
 
8
  abstract class LoaderAbstract implements LoaderInterface
9
  {
@@ -21,7 +20,7 @@
21
 
22
  public function initHooks()
23
  {
24
- if (!static::isActiveLoader() || get_option(Errors::ERRORS_CACHE_OPTION, [])) {
25
  return;
26
  }
27
  $this->hooks();
3
  namespace WebpConverter\Loader;
4
 
5
  use WebpConverter\Loader\LoaderInterface;
 
6
 
7
  abstract class LoaderAbstract implements LoaderInterface
8
  {
20
 
21
  public function initHooks()
22
  {
23
+ if (!static::isActiveLoader() || apply_filters('webpc_server_errors', [], true)) {
24
  return;
25
  }
26
  $this->hooks();
app/Method/MethodAbstract.php CHANGED
@@ -2,9 +2,10 @@
2
 
3
  namespace WebpConverter\Method;
4
 
5
- use WebpConverter\Method\MethodInterface;
6
  use WebpConverter\Convert\Directory;
7
  use WebpConverter\Convert\Server;
 
 
8
 
9
  abstract class MethodAbstract implements MethodInterface
10
  {
@@ -33,6 +34,10 @@
33
  $image = $this->createImageByPath($sourcePath);
34
  $outputPath = $this->getImageOutputPath($sourcePath);
35
 
 
 
 
 
36
  $this->convertImageToWebP($image, $sourcePath, $outputPath);
37
  do_action('webpc_convert_after', $outputPath, $sourcePath);
38
 
2
 
3
  namespace WebpConverter\Method;
4
 
 
5
  use WebpConverter\Convert\Directory;
6
  use WebpConverter\Convert\Server;
7
+ use WebpConverter\Convert\Size;
8
+ use WebpConverter\Method\MethodInterface;
9
 
10
  abstract class MethodAbstract implements MethodInterface
11
  {
34
  $image = $this->createImageByPath($sourcePath);
35
  $outputPath = $this->getImageOutputPath($sourcePath);
36
 
37
+ if (file_exists($outputPath . Size::DELETED_FILE_EXTENSION)) {
38
+ unlink($outputPath . Size::DELETED_FILE_EXTENSION);
39
+ }
40
+
41
  $this->convertImageToWebP($image, $sourcePath, $outputPath);
42
  do_action('webpc_convert_after', $outputPath, $sourcePath);
43
 
app/Method/MethodIntegrator.php CHANGED
@@ -4,7 +4,6 @@
4
 
5
  use WebpConverter\Method\Gd;
6
  use WebpConverter\Method\Imagick;
7
- use WebpConverter\Settings\Errors;
8
 
9
  class MethodIntegrator
10
  {
@@ -26,7 +25,7 @@
26
 
27
  public function getMethodUsed($methodKey)
28
  {
29
- if (get_option(Errors::ERRORS_CACHE_OPTION, [])) {
30
  return null;
31
  }
32
 
4
 
5
  use WebpConverter\Method\Gd;
6
  use WebpConverter\Method\Imagick;
 
7
 
8
  class MethodIntegrator
9
  {
25
 
26
  public function getMethodUsed($methodKey)
27
  {
28
+ if (apply_filters('webpc_server_errors', [], true)) {
29
  return null;
30
  }
31
 
app/Plugin/Uninstall.php CHANGED
@@ -3,9 +3,10 @@
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\Admin\Notice;
6
- use WebpConverter\Settings\Save;
7
- use WebpConverter\Settings\Errors;
8
  use WebpConverter\Error\RewritesError;
 
 
9
 
10
  class Uninstall
11
  {
@@ -34,7 +35,9 @@
34
  private static function removeHtaccessFile()
35
  {
36
  $path = sprintf('%s/.htaccess', apply_filters('webpc_dir_path', '', 'webp'));
37
- if (is_writable($path)) unlink($path);
 
 
38
  }
39
 
40
  public static function removeWebpFiles()
@@ -63,7 +66,9 @@
63
  $path .= '/';
64
  $files = glob($path . '*');
65
  foreach ($files as $file) {
66
- if (is_dir($file)) $paths = self::getPathsFromLocation($file, $paths);
 
 
67
  $paths[] = $file;
68
  }
69
  return $paths;
@@ -71,11 +76,22 @@
71
 
72
  private static function removeFiles($paths)
73
  {
74
- if (!$paths) return;
 
 
 
 
75
  foreach ($paths as $path) {
76
- if (!is_writable($path) || !is_writable(dirname($path))) continue;
77
- if (is_file($path) && (pathinfo($path, PATHINFO_EXTENSION) === 'webp')) unlink($path);
78
- else if (is_dir($path)) rmdir($path);
 
 
 
 
 
 
 
79
  }
80
  }
81
  }
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\Admin\Notice;
6
+ use WebpConverter\Convert\Size;
 
7
  use WebpConverter\Error\RewritesError;
8
+ use WebpConverter\Settings\Errors;
9
+ use WebpConverter\Settings\Save;
10
 
11
  class Uninstall
12
  {
35
  private static function removeHtaccessFile()
36
  {
37
  $path = sprintf('%s/.htaccess', apply_filters('webpc_dir_path', '', 'webp'));
38
+ if (is_writable($path)) {
39
+ unlink($path);
40
+ }
41
  }
42
 
43
  public static function removeWebpFiles()
66
  $path .= '/';
67
  $files = glob($path . '*');
68
  foreach ($files as $file) {
69
+ if (is_dir($file)) {
70
+ $paths = self::getPathsFromLocation($file, $paths);
71
+ }
72
  $paths[] = $file;
73
  }
74
  return $paths;
76
 
77
  private static function removeFiles($paths)
78
  {
79
+ if (!$paths) {
80
+ return;
81
+ }
82
+
83
+ $deletedExtension = trim(Size::DELETED_FILE_EXTENSION, '.');
84
  foreach ($paths as $path) {
85
+ if (!is_writable($path) || !is_writable(dirname($path))) {
86
+ continue;
87
+ }
88
+
89
+ $extension = pathinfo($path, PATHINFO_EXTENSION);
90
+ if (is_file($path) && in_array($extension, ['webp', $deletedExtension])) {
91
+ unlink($path);
92
+ } else if (is_dir($path)) {
93
+ rmdir($path);
94
+ }
95
  }
96
  }
97
  }
app/Plugin/Update.php CHANGED
@@ -3,8 +3,8 @@
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\Loader\LoaderAbstract;
6
- use WebpConverter\Settings\Save;
7
  use WebpConverter\Plugin\Uninstall;
 
8
 
9
  class Update
10
  {
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\Loader\LoaderAbstract;
 
6
  use WebpConverter\Plugin\Uninstall;
7
+ use WebpConverter\Settings\Save;
8
 
9
  class Update
10
  {
app/Regenerate/Skip.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Regenerate;
4
 
5
  use WebpConverter\Convert\Directory;
 
6
 
7
  class Skip
8
  {
@@ -21,8 +22,10 @@
21
 
22
  $directory = new Directory();
23
  foreach ($paths as $key => $path) {
24
- $output = $directory->getPath($path, false);
25
- if (file_exists($output)) unset($paths[$key]);
 
 
26
  }
27
  return $paths;
28
  }
3
  namespace WebpConverter\Regenerate;
4
 
5
  use WebpConverter\Convert\Directory;
6
+ use WebpConverter\Convert\Size;
7
 
8
  class Skip
9
  {
22
 
23
  $directory = new Directory();
24
  foreach ($paths as $key => $path) {
25
+ $output = $directory->getPath(urldecode($path), false);
26
+ if (file_exists($output) || file_exists($output . Size::DELETED_FILE_EXTENSION)) {
27
+ unset($paths[$key]);
28
+ }
29
  }
30
  return $paths;
31
  }
app/Settings/Errors.php CHANGED
@@ -13,37 +13,48 @@
13
  {
14
  const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
15
 
16
- private $cache = null;
17
- private $filePath = WEBPC_PATH . '/resources/components/errors/%s.php';
 
18
 
19
  public function __construct()
20
  {
21
- add_filter('webpc_server_errors', [$this, 'getServerErrors']);
 
22
  }
23
 
24
  /* ---
25
  Functions
26
  --- */
27
 
28
- public function getServerErrors()
29
  {
30
- if ($this->cache !== null) return $this->cache;
 
 
 
 
 
 
 
 
 
31
 
32
- $this->cache = $this->loadErrorMessages();
33
- return $this->cache;
 
 
34
  }
35
 
36
- private function loadErrorMessages()
37
  {
38
- $errors = $this->getErrorsList();
39
- $list = [];
40
  foreach ($errors as $error) {
41
  ob_start();
42
  include sprintf($this->filePath, str_replace('_', '-', $error));
43
  $list[$error] = ob_get_clean();
44
  }
45
 
46
- update_option(self::ERRORS_CACHE_OPTION, array_keys($list));
47
  return $list;
48
  }
49
 
@@ -68,6 +79,9 @@
68
  $errors = array_merge($errors, $newErrors);
69
  }
70
 
 
 
 
71
  return $errors;
72
  }
73
 
13
  {
14
  const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
15
 
16
+ private $cache = [];
17
+ private $filePath = WEBPC_PATH . '/resources/components/errors/%s.php';
18
+ private $allowedErrors = ['rewrites_cached'];
19
 
20
  public function __construct()
21
  {
22
+ add_filter('webpc_server_errors', [$this, 'getServerErrors'], 10, 3);
23
+ add_filter('webpc_server_errors_messages', [$this, 'getServerErrorsMessages'], 10, 3);
24
  }
25
 
26
  /* ---
27
  Functions
28
  --- */
29
 
30
+ public function getServerErrors($values, $onlyErrors = false, $isForceRefresh = false)
31
  {
32
+ $errors = get_option(self::ERRORS_CACHE_OPTION, $this->cache);
33
+ if ($isForceRefresh) {
34
+ $errors = $this->getErrorsList();
35
+ }
36
+ $errors = array_filter($errors, function($error) use ($onlyErrors) {
37
+ return (!$onlyErrors || !in_array($error, $this->allowedErrors));
38
+ });
39
+
40
+ return $errors;
41
+ }
42
 
43
+ public function getServerErrorsMessages($values, $onlyErrors = false, $isForceRefresh = false)
44
+ {
45
+ $errors = $this->getServerErrors($values, $onlyErrors, $isForceRefresh);
46
+ return $this->loadErrorMessages($errors);
47
  }
48
 
49
+ private function loadErrorMessages($errors)
50
  {
51
+ $list = [];
 
52
  foreach ($errors as $error) {
53
  ob_start();
54
  include sprintf($this->filePath, str_replace('_', '-', $error));
55
  $list[$error] = ob_get_clean();
56
  }
57
 
 
58
  return $list;
59
  }
60
 
79
  $errors = array_merge($errors, $newErrors);
80
  }
81
 
82
+ $this->cache = $errors;
83
+ update_option(self::ERRORS_CACHE_OPTION, $errors);
84
+
85
  return $errors;
86
  }
87
 
app/Settings/Server.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  namespace WebpConverter\Settings;
4
 
 
5
  use WebpConverter\Loader\LoaderAbstract;
6
  use WebpConverter\Settings\Errors;
7
- use WebpConverter\Error\RewritesError;
8
  use WebpConverter\Traits\FileLoaderTrait;
9
 
10
  class Server
2
 
3
  namespace WebpConverter\Settings;
4
 
5
+ use WebpConverter\Error\RewritesError;
6
  use WebpConverter\Loader\LoaderAbstract;
7
  use WebpConverter\Settings\Errors;
 
8
  use WebpConverter\Traits\FileLoaderTrait;
9
 
10
  class Server
libs/passthru.php CHANGED
@@ -25,7 +25,10 @@
25
 
26
  private function loadImageWebP($imageUrl)
27
  {
28
- $header = getallheaders()['Accept'] ?? '';
 
 
 
29
  if ((strpos($header, 'image/webp') === false)
30
  || (!$source = $this->loadWebpSource($imageUrl))) {
31
  return $this->loadImageDefault($imageUrl);
25
 
26
  private function loadImageWebP($imageUrl)
27
  {
28
+ $header = function_exists('getallheaders')
29
+ ? (getallheaders()['Accept'] ?? '')
30
+ : ($_SERVER['HTTP_ACCEPT'] ?? '');
31
+
32
  if ((strpos($header, 'image/webp') === false)
33
  || (!$source = $this->loadWebpSource($imageUrl))) {
34
  return $this->loadImageDefault($imageUrl);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mateuszgbiorczyk
3
  Donate link: https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=readme-donate
4
  Tags: convert webp, webp, optimize images, images, webp converter, performance, optimisation
5
  Requires at least: 4.9
6
- Tested up to: 5.6
7
  Requires PHP: 7.0
8
  Stable tag: trunk
9
  License: GPLv2 or later
@@ -69,7 +69,7 @@ Please always adding your thread, **read all other questions in the FAQ of plugi
69
 
70
  When adding a thread, follow these steps and reply to each of them:
71
 
72
- **1.** Do you have any error on the plugin settings page? Enter error codes. Have you consulted your server administrator or developer?
73
 
74
  **2.** URL of your website. If your site is not publicly available, add it to test environment.
75
 
@@ -103,6 +103,18 @@ When contacting the administrator, give him all the information available in the
103
 
104
  We want to solve as many similar problems as possible automatically. This eliminates the need to wait for our response and you can try to solve the problem alone. This is very important for us.
105
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  = Error while converting? =
107
 
108
  You can get several types of errors when converting. First of all, carefully read their content. For the most part, you can solve this problem yourself. Try to do this or contact the server administrator.
@@ -133,26 +145,6 @@ In a situation where your server does not meet the technical requirements, pleas
133
 
134
  Also REST API must be enabled and work without additional restrictions. If you have a problem with it, please contact the Developer who created your website. He should easily find the issue with the REST API not working.
135
 
136
- = What are restrictions? =
137
-
138
- The size of the image is a limited. Its resolution cannot be bigger than `8192 x 8192px`. This is due to the limitations of the PHP library.
139
-
140
- Please remember that **Safari *(version 13 or earlier)* and Internet Explorer do not support the WebP format**. Therefore, using these browsers you will receive original images.
141
-
142
- You can find more about WebP support by browsers [here](https://caniuse.com/#feat=webp).
143
-
144
- = Damaged images on iOS or other browsers =
145
-
146
- The plugin in default loading mode *(via .htaccess)* uses rules in the .htaccess file to redirect from the original image to an image in WebP format. Verifies whether the WebP file exists and whether your browser supports the WebP format. It does this every time you try to load an image.
147
-
148
- When you enter from a WebP supporting device, it will redirect. However, when someone uses a browser that does not support WebP, the redirection will not work and you get the original file.
149
-
150
- However, if you see corrupted images on browsers that do not support WebP, it means that your server uses cache for rewrites from the .htaccess file. Then the plugin will not work properly because the server instead of reading the rules from the .htaccess file every time uses its cache and does the redirection automatically.
151
-
152
- How can you check it? When you turn off the plugin, the rewrites from the .htaccess file are removed, which means you should see the original images on every browser. If this is not the case and you see forced redirects to WebP files, it means that your server remembers the redirects you made earlier and uses cache.
153
-
154
- In this situation, please contact your server administrator. Each configuration is different. It can be e.g. module `mod_pagespeed` or other similar. This functionality must be turned off so that the server reads and executes the rules from the .htaccess file each time the images are loaded. This cannot be ignored because it will cause problems.
155
-
156
  = What to do after installing plugin? =
157
 
158
  After installing the plugin, you should convert all existing images.
@@ -192,6 +184,8 @@ Only images from the `/uploads` directory are automatically converted. If you us
192
 
193
  If the converted image in WebP format is larger than the original, the browser will use the original file. This converted file will be deleted. Therefore, you can also see files other than WebP on the list. When this happens, you will receive information in debug.log.
194
 
 
 
195
  If you want to force the use of WebP files, uncheck the `Automatic removal of WebP files larger than original` option in the plugin settings. Then click on the `Regenerate All` button to convert all images again.
196
 
197
  Remember that this plugin supports images from the `/wp-content` directory, e.g. files downloaded from the Media Library. Redirections will not work if your images are downloaded from another domain, i.e. from an external service.
@@ -365,12 +359,6 @@ All rules from the files `/wp-content/.htaccess`, `/wp-content/uploads/.htaccess
365
 
366
  Argument `$path` is absolute server path for `.htaccess` file.
367
 
368
- = What is Browser Caching? =
369
-
370
- This option allows you to speed up page loading time for returning users because they do not need to re-download files from the server. The plugin allows this by using the module `mod_expires`.
371
-
372
- It is enabled by default. If you do not want to use this functionality, you can turn it off at any time.
373
-
374
  = Does plugin support CDN? =
375
 
376
  Unfortunately not. This is due to the logic of the plugin's operation. Plugins that enable integration with the CDN servers modify the HTML of the website, changing URLs for media files. This plugin does not modify URLs. Replacing URLs in the HTML code is not an optimal solution.
@@ -483,6 +471,12 @@ This is all very important to us and allows us to do even better things for you!
483
 
484
  == Changelog ==
485
 
 
 
 
 
 
 
486
  = 2.3.0 (2021-01-31) =
487
  * `[Fixed]` Encoding paths to files
488
  * `[Fixed]` Retaining PNG transparency using Gd method
@@ -677,4 +671,4 @@ This is all very important to us and allows us to do even better things for you!
677
 
678
  == Upgrade Notice ==
679
 
680
- None.
3
  Donate link: https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=readme-donate
4
  Tags: convert webp, webp, optimize images, images, webp converter, performance, optimisation
5
  Requires at least: 4.9
6
+ Tested up to: 5.7
7
  Requires PHP: 7.0
8
  Stable tag: trunk
9
  License: GPLv2 or later
69
 
70
  When adding a thread, follow these steps and reply to each of them:
71
 
72
+ **1.** Do you have any error on the plugin settings page? Enter error codes. Have you consulted your server administrator or developer?
73
 
74
  **2.** URL of your website. If your site is not publicly available, add it to test environment.
75
 
103
 
104
  We want to solve as many similar problems as possible automatically. This eliminates the need to wait for our response and you can try to solve the problem alone. This is very important for us.
105
 
106
+ = Server configuration error on Cloudflare =
107
+
108
+ For Cloudflare servers, a recurring problem is the error code **rewrites_cached** that is displayed on the plugin settings page. To solve this problem, you need to disable the cache for the website from the server.
109
+
110
+ Please follow the steps below:
111
+ **1.** Enter Cloudflare management panel and then to **Page Rules** Tab.
112
+ **2.** Click **Create page rule** button.
113
+ **3.** Enter your domain name (example: **yourdomain.com/\***).
114
+ **4.** Choose **Cache Level** option, set **Bypass** value and click **Save** button.
115
+ **5.** Click **Save and Deploy** button.
116
+ **6.** Wait, it may take several minutes for the changes to be deployed.
117
+
118
  = Error while converting? =
119
 
120
  You can get several types of errors when converting. First of all, carefully read their content. For the most part, you can solve this problem yourself. Try to do this or contact the server administrator.
145
 
146
  Also REST API must be enabled and work without additional restrictions. If you have a problem with it, please contact the Developer who created your website. He should easily find the issue with the REST API not working.
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  = What to do after installing plugin? =
149
 
150
  After installing the plugin, you should convert all existing images.
184
 
185
  If the converted image in WebP format is larger than the original, the browser will use the original file. This converted file will be deleted. Therefore, you can also see files other than WebP on the list. When this happens, you will receive information in debug.log.
186
 
187
+ When such a situation occurs, a file in `.webp.deleted` format will be created. This avoids re-converting images that were larger than original after converting to WebP. If the option of forced conversion of all images is checked, this image will also be re-converted.
188
+
189
  If you want to force the use of WebP files, uncheck the `Automatic removal of WebP files larger than original` option in the plugin settings. Then click on the `Regenerate All` button to convert all images again.
190
 
191
  Remember that this plugin supports images from the `/wp-content` directory, e.g. files downloaded from the Media Library. Redirections will not work if your images are downloaded from another domain, i.e. from an external service.
359
 
360
  Argument `$path` is absolute server path for `.htaccess` file.
361
 
 
 
 
 
 
 
362
  = Does plugin support CDN? =
363
 
364
  Unfortunately not. This is due to the logic of the plugin's operation. Plugins that enable integration with the CDN servers modify the HTML of the website, changing URLs for media files. This plugin does not modify URLs. Replacing URLs in the HTML code is not an optimal solution.
471
 
472
  == Changelog ==
473
 
474
+ = 2.4.0 (2021-02-28) =
475
+ * `[Fixed]` Error detection of redirects without .png as supported file extension
476
+ * `[Fixed]` Pass Thru loading mode for servers not supporting `getallheaders()` function
477
+ * `[Changed]` Level of error for cached redirects of images to WebP files
478
+ * `[Added]` Skip re-converting images that were larger than original after converting to WebP
479
+
480
  = 2.3.0 (2021-01-31) =
481
  * `[Fixed]` Encoding paths to files
482
  * `[Fixed]` Retaining PNG transparency using Gd method
671
 
672
  == Upgrade Notice ==
673
 
674
+ None.
resources/components/widgets/errors.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php if ($errors = apply_filters('webpc_server_errors', [])) : ?>
2
  <div class="webpPage__widget">
3
  <h3 class="webpPage__widgetTitle webpPage__widgetTitle--error">
4
  <?= esc_html(__('Server configuration error', 'webp-converter-for-media')); ?>
1
+ <?php if ($errors = apply_filters('webpc_server_errors_messages', [], false, true)) : ?>
2
  <div class="webpPage__widget">
3
  <h3 class="webpPage__widgetTitle webpPage__widgetTitle--error">
4
  <?= esc_html(__('Server configuration error', 'webp-converter-for-media')); ?>
resources/components/widgets/regenerate.php CHANGED
@@ -88,7 +88,7 @@
88
  </table>
89
  <button type="button" target="_blank"
90
  class="webpLoader__button webpButton webpButton--green"
91
- <?= (apply_filters('webpc_server_errors', [])) ? 'disabled' : ''; ?>>
92
  <?= esc_html(__('Regenerate All', 'webp-converter-for-media')); ?>
93
  </button>
94
  </div>
88
  </table>
89
  <button type="button" target="_blank"
90
  class="webpLoader__button webpButton webpButton--green"
91
+ <?= (apply_filters('webpc_server_errors', [], true)) ? 'disabled' : ''; ?>>
92
  <?= esc_html(__('Regenerate All', 'webp-converter-for-media')); ?>
93
  </button>
94
  </div>
resources/views/deactivation-modal.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  use WebpConverter\Settings\Errors;
4
 
5
- $errors = implode(', ', get_option(Errors::ERRORS_CACHE_OPTION, []));
6
  $items = [
7
  [
8
  'key' => 'server_config',
2
 
3
  use WebpConverter\Settings\Errors;
4
 
5
+ $errors = implode(', ', apply_filters('webpc_server_errors', []));
6
  $items = [
7
  [
8
  'key' => 'server_config',
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitf6f394339146bc91ffde2c0ccd9f5844::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitbf2d1e8ab3a1950ed7aef886b373c248::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitf6f394339146bc91ffde2c0ccd9f5844
6
  {
7
  private static $loader;
8
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInitf6f394339146bc91ffde2c0ccd9f5844
22
  return self::$loader;
23
  }
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInitf6f394339146bc91ffde2c0ccd9f5844', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
- spl_autoload_unregister(array('ComposerAutoloaderInitf6f394339146bc91ffde2c0ccd9f5844', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require_once __DIR__ . '/autoload_static.php';
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInitf6f394339146bc91ffde2c0ccd9f5844::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitbf2d1e8ab3a1950ed7aef886b373c248
6
  {
7
  private static $loader;
8
 
22
  return self::$loader;
23
  }
24
 
25
+ spl_autoload_register(array('ComposerAutoloaderInitbf2d1e8ab3a1950ed7aef886b373c248', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27
+ spl_autoload_unregister(array('ComposerAutoloaderInitbf2d1e8ab3a1950ed7aef886b373c248', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require_once __DIR__ . '/autoload_static.php';
32
 
33
+ call_user_func(\Composer\Autoload\ComposerStaticInitbf2d1e8ab3a1950ed7aef886b373c248::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitf6f394339146bc91ffde2c0ccd9f5844
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
@@ -23,8 +23,8 @@ class ComposerStaticInitf6f394339146bc91ffde2c0ccd9f5844
23
  public static function getInitializer(ClassLoader $loader)
24
  {
25
  return \Closure::bind(function () use ($loader) {
26
- $loader->prefixLengthsPsr4 = ComposerStaticInitf6f394339146bc91ffde2c0ccd9f5844::$prefixLengthsPsr4;
27
- $loader->prefixDirsPsr4 = ComposerStaticInitf6f394339146bc91ffde2c0ccd9f5844::$prefixDirsPsr4;
28
 
29
  }, null, ClassLoader::class);
30
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInitbf2d1e8ab3a1950ed7aef886b373c248
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
23
  public static function getInitializer(ClassLoader $loader)
24
  {
25
  return \Closure::bind(function () use ($loader) {
26
+ $loader->prefixLengthsPsr4 = ComposerStaticInitbf2d1e8ab3a1950ed7aef886b373c248::$prefixLengthsPsr4;
27
+ $loader->prefixDirsPsr4 = ComposerStaticInitbf2d1e8ab3a1950ed7aef886b373c248::$prefixDirsPsr4;
28
 
29
  }, null, ClassLoader::class);
30
  }
webp-converter-for-media.php CHANGED
@@ -3,14 +3,14 @@
3
  /*
4
  Plugin Name: WebP Converter for Media
5
  Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
- Version: 2.3.0
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter-for-media
10
  Network: true
11
  */
12
 
13
- define('WEBPC_VERSION', '2.3.0');
14
  define('WEBPC_FILE', __FILE__);
15
  define('WEBPC_NAME', plugin_basename(__FILE__));
16
  define('WEBPC_PATH', plugin_dir_path(__FILE__));
3
  /*
4
  Plugin Name: WebP Converter for Media
5
  Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
+ Version: 2.4.0
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter-for-media
10
  Network: true
11
  */
12
 
13
+ define('WEBPC_VERSION', '2.4.0');
14
  define('WEBPC_FILE', __FILE__);
15
  define('WEBPC_NAME', plugin_basename(__FILE__));
16
  define('WEBPC_PATH', plugin_dir_path(__FILE__));