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

Version Description

(2020-10-28) = * [Added] Filter webpc_files_paths to modify paths of images to be converted * [Added] Filter webpc_convert_error to management of errors content displayed during conversion * [Added] Filter webpc_convert_errors to management of errors displayed during conversion

Download this release

Release Info

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

Code changes from version 1.4.6 to 1.5.0

app/Admin/Plugin.php CHANGED
@@ -29,7 +29,7 @@
29
  {
30
  $links[] = sprintf(
31
  __('%sProvide us a coffee%s', 'webp-converter-for-media'),
32
- '<a href="https://ko-fi.com/gbiorczyk/" target="_blank">',
33
  '</a>'
34
  );
35
  return $links;
29
  {
30
  $links[] = sprintf(
31
  __('%sProvide us a coffee%s', 'webp-converter-for-media'),
32
+ '<a href="https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=plugin-links" target="_blank">',
33
  '</a>'
34
  );
35
  return $links;
app/Convert/Dir.php CHANGED
@@ -21,7 +21,7 @@
21
  $excluded = apply_filters('webpc_dir_excluded', []);
22
 
23
  $paths = $this->findFilesInDirectory($dirPath, $settings['extensions'], $excluded);
24
- return apply_filters('webpc_attachment_paths', $paths, $skipExists);
25
  }
26
 
27
  private function findFilesInDirectory($dirPath, $allowedExts, $excludedDirs)
21
  $excluded = apply_filters('webpc_dir_excluded', []);
22
 
23
  $paths = $this->findFilesInDirectory($dirPath, $settings['extensions'], $excluded);
24
+ return apply_filters('webpc_files_paths', $paths, $skipExists);
25
  }
26
 
27
  private function findFilesInDirectory($dirPath, $allowedExts, $excludedDirs)
app/Convert/Size.php CHANGED
@@ -21,9 +21,11 @@
21
  || (filesize($webpPath) < filesize($originalPath))) return;
22
 
23
  unlink($webpPath);
24
- throw new \Exception(sprintf(
25
  'Image "%s" converted to WebP is larger than original and has been deleted.',
26
  $originalPath
27
  ));
 
 
28
  }
29
  }
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
27
  ));
28
+ $e->status = 'larger_than_original';
29
+ throw $e;
30
  }
31
  }
app/Media/Attachment.php CHANGED
@@ -35,6 +35,7 @@
35
 
36
  $paths = $this->getPathsBySizes($postId, $metadata['file']);
37
  $paths = apply_filters('webpc_attachment_paths', $paths, $postId);
 
38
  return $paths;
39
  }
40
 
35
 
36
  $paths = $this->getPathsBySizes($postId, $metadata['file']);
37
  $paths = apply_filters('webpc_attachment_paths', $paths, $postId);
38
+ $paths = apply_filters('webpc_files_paths', $paths, false);
39
  return $paths;
40
  }
41
 
app/Media/Upload.php CHANGED
@@ -21,6 +21,7 @@
21
 
22
  $paths = $this->getSizesPaths($data);
23
  $paths = apply_filters('webpc_attachment_paths', $paths, $attachmentId);
 
24
 
25
  $paths = array_diff($paths, $this->convertedPaths);
26
  $this->convertedPaths = array_merge($this->convertedPaths, $paths);
21
 
22
  $paths = $this->getSizesPaths($data);
23
  $paths = apply_filters('webpc_attachment_paths', $paths, $attachmentId);
24
+ $paths = apply_filters('webpc_files_paths', $paths, false);
25
 
26
  $paths = array_diff($paths, $this->convertedPaths);
27
  $this->convertedPaths = array_merge($this->convertedPaths, $paths);
app/Method/Gd.php CHANGED
@@ -17,23 +17,42 @@
17
 
18
  try {
19
  $status = (new Server())->checkIfFileExists($path);
20
- if ($status !== true) throw new \Exception($status);
 
 
 
 
21
 
22
  $response = $this->createImage($path);
23
- if (!$response['success']) throw new \Exception($response['message']);
24
- else $image = $response['data'];
 
 
 
 
 
25
 
26
  $response = $this->convertColorPalette($image, $path);
27
- if (!$response['success']) throw new \Exception($response['message']);
28
- else $image = $response['data'];
 
 
 
 
 
29
 
30
  $image = apply_filters('webpc_gd_before_saving', $image, $path);
31
  $response = $this->convertToWebp($image, $path, $settings);
32
- if (!$response['success']) throw new \Exception($response['message']);
33
- else return [
34
- 'success' => true,
35
- 'data' => $response['data'],
36
- ];
 
 
 
 
 
37
  } catch (\Exception $e) {
38
  if (in_array('debug_enabled', $settings['features'])) {
39
  error_log(sprintf('WebP Converter for Media: %s', $e->getMessage()));
@@ -41,7 +60,7 @@
41
 
42
  return [
43
  'success' => false,
44
- 'message' => $e->getMessage(),
45
  ];
46
  }
47
  }
@@ -59,13 +78,19 @@
59
  if (!in_array($extension, $extensions)) {
60
  continue;
61
  } else if (!function_exists($method)) {
62
- throw new \Exception(sprintf('Server configuration: "%s" function is not available.', $method));
 
 
63
  } else if (!$image = @$method($path)) {
64
- throw new \Exception(sprintf('"%s" is not a valid image file.', $path));
 
 
65
  }
66
  }
67
  if (!isset($image)) {
68
- throw new \Exception(sprintf('Unsupported extension "%s" for file "%s"', $extension, $path));
 
 
69
  }
70
 
71
  return [
@@ -74,8 +99,9 @@
74
  ];
75
  } catch (\Exception $e) {
76
  return [
77
- 'success' => false,
78
- 'message' => $e->getMessage(),
 
79
  ];
80
  }
81
  }
@@ -84,10 +110,14 @@
84
  {
85
  try {
86
  if (!function_exists('imageistruecolor')) {
87
- throw new \Exception(sprintf('Server configuration: "%s" function is not available.', 'imageistruecolor'));
 
 
88
  } else if (!imageistruecolor($image)) {
89
  if (!function_exists('imagepalettetotruecolor')) {
90
- throw new \Exception(sprintf('Server configuration: "%s" function is not available.', 'imagepalettetotruecolor'));
 
 
91
  }
92
  imagepalettetotruecolor($image);
93
  }
@@ -98,8 +128,9 @@
98
  ];
99
  } catch (\Exception $e) {
100
  return [
101
- 'success' => false,
102
- 'message' => $e->getMessage(),
 
103
  ];
104
  }
105
  }
@@ -109,13 +140,21 @@
109
  try {
110
  $output = (new Directory())->getPath($path, true);
111
  if (!$output) {
112
- throw new \Exception(sprintf('An error occurred creating destination directory for "%s" file.', $path));
 
 
113
  } else if (!function_exists('imagewebp')) {
114
- throw new \Exception(sprintf('Server configuration: "%s" function is not available.', 'imagewebp'));
 
 
115
  } else if ((imagesx($image) > 8192) || (imagesy($image) > 8192)) {
116
- throw new \Exception(sprintf('Image is larger than maximum 8K resolution: "%s".', $path));
 
 
117
  } else if (!$success = imagewebp($image, $output, $settings['quality'])) {
118
- throw new \Exception(sprintf('Error occurred while converting image: "%s".', $path));
 
 
119
  }
120
 
121
  if (filesize($output) % 2 === 1) file_put_contents($output, "\0", FILE_APPEND);
@@ -132,8 +171,9 @@
132
  ];
133
  } catch (\Exception $e) {
134
  return [
135
- 'success' => false,
136
- 'message' => $e->getMessage(),
 
137
  ];
138
  }
139
 
17
 
18
  try {
19
  $status = (new Server())->checkIfFileExists($path);
20
+ if ($status !== true) {
21
+ $e = new \Exception($status);
22
+ $e->status = 'file_unreadable';
23
+ throw $e;
24
+ }
25
 
26
  $response = $this->createImage($path);
27
+ if (!$response['success']) {
28
+ $e = new \Exception($response['message']);
29
+ $e->status = isset($response['error_code']) ? $response['error_code'] : '';
30
+ throw $e;
31
+ } else {
32
+ $image = $response['data'];
33
+ }
34
 
35
  $response = $this->convertColorPalette($image, $path);
36
+ if (!$response['success']) {
37
+ $e = new \Exception($response['message']);
38
+ $e->status = isset($response['error_code']) ? $response['error_code'] : '';
39
+ throw $e;
40
+ } else {
41
+ $image = $response['data'];
42
+ }
43
 
44
  $image = apply_filters('webpc_gd_before_saving', $image, $path);
45
  $response = $this->convertToWebp($image, $path, $settings);
46
+ if (!$response['success']) {
47
+ $e = new \Exception($response['message']);
48
+ $e->status = isset($response['error_code']) ? $response['error_code'] : '';
49
+ throw $e;
50
+ } else {
51
+ return [
52
+ 'success' => true,
53
+ 'data' => $response['data'],
54
+ ];
55
+ }
56
  } catch (\Exception $e) {
57
  if (in_array('debug_enabled', $settings['features'])) {
58
  error_log(sprintf('WebP Converter for Media: %s', $e->getMessage()));
60
 
61
  return [
62
  'success' => false,
63
+ 'message' => apply_filters('webpc_convert_error', $e->getMessage(), $e->status),
64
  ];
65
  }
66
  }
78
  if (!in_array($extension, $extensions)) {
79
  continue;
80
  } else if (!function_exists($method)) {
81
+ $e = new \Exception(sprintf('Server configuration: "%s" function is not available.', $method));
82
+ $e->status = 'server_configuration';
83
+ throw $e;
84
  } else if (!$image = @$method($path)) {
85
+ $e = new \Exception(sprintf('"%s" is not a valid image file.', $path));
86
+ $e->status = 'invalid_image';
87
+ throw $e;
88
  }
89
  }
90
  if (!isset($image)) {
91
+ $e = new \Exception(sprintf('Unsupported extension "%s" for file "%s"', $extension, $path));
92
+ $e->status = 'unsupported_extension';
93
+ throw $e;
94
  }
95
 
96
  return [
99
  ];
100
  } catch (\Exception $e) {
101
  return [
102
+ 'success' => false,
103
+ 'message' => $e->getMessage(),
104
+ 'error_code' => (isset($e->status)) ? $e->status : '',
105
  ];
106
  }
107
  }
110
  {
111
  try {
112
  if (!function_exists('imageistruecolor')) {
113
+ $e = new \Exception(sprintf('Server configuration: "%s" function is not available.', 'imageistruecolor'));
114
+ $e->status = 'server_configuration';
115
+ throw $e;
116
  } else if (!imageistruecolor($image)) {
117
  if (!function_exists('imagepalettetotruecolor')) {
118
+ $e = new \Exception(sprintf('Server configuration: "%s" function is not available.', 'imagepalettetotruecolor'));
119
+ $e->status = 'server_configuration';
120
+ throw $e;
121
  }
122
  imagepalettetotruecolor($image);
123
  }
128
  ];
129
  } catch (\Exception $e) {
130
  return [
131
+ 'success' => false,
132
+ 'message' => $e->getMessage(),
133
+ 'error_code' => (isset($e->status)) ? $e->status : '',
134
  ];
135
  }
136
  }
140
  try {
141
  $output = (new Directory())->getPath($path, true);
142
  if (!$output) {
143
+ $e = new \Exception(sprintf('An error occurred creating destination directory for "%s" file.', $path));
144
+ $e->status = 'output_path';
145
+ throw $e;
146
  } else if (!function_exists('imagewebp')) {
147
+ $e = new \Exception(sprintf('Server configuration: "%s" function is not available.', 'imagewebp'));
148
+ $e->status = 'server_configuration';
149
+ throw $e;
150
  } else if ((imagesx($image) > 8192) || (imagesy($image) > 8192)) {
151
+ $e = new \Exception(sprintf('Image is larger than maximum 8K resolution: "%s".', $path));
152
+ $e->status = 'max_resolution';
153
+ throw $e;
154
  } else if (!$success = imagewebp($image, $output, $settings['quality'])) {
155
+ $e = new \Exception(sprintf('Error occurred while converting image: "%s".', $path));
156
+ $e->status = 'convert_error';
157
+ throw $e;
158
  }
159
 
160
  if (filesize($output) % 2 === 1) file_put_contents($output, "\0", FILE_APPEND);
171
  ];
172
  } catch (\Exception $e) {
173
  return [
174
+ 'success' => false,
175
+ 'message' => $e->getMessage(),
176
+ 'error_code' => (isset($e->status)) ? $e->status : '',
177
  ];
178
  }
179
 
app/Method/Imagick.php CHANGED
@@ -17,19 +17,33 @@
17
 
18
  try {
19
  $status = (new Server())->checkIfFileExists($path);
20
- if ($status !== true) throw new \Exception($status);
 
 
 
 
21
 
22
  $response = $this->createImage($path);
23
- if (!$response['success']) throw new \Exception($response['message']);
24
- else $image = $response['data'];
 
 
 
 
 
25
 
26
  $image = apply_filters('webpc_imagick_before_saving', $image, $path);
27
  $response = $this->convertToWebp($image, $path, $settings);
28
- if (!$response['success']) throw new \Exception($response['message']);
29
- else return [
30
- 'success' => true,
31
- 'data' => $response['data'],
32
- ];
 
 
 
 
 
33
  } catch (\Exception $e) {
34
  if (in_array('debug_enabled', $settings['features'])) {
35
  error_log(sprintf('WebP Converter for Media: %s', $e->getMessage()));
@@ -37,7 +51,7 @@
37
 
38
  return [
39
  'success' => false,
40
- 'message' => $e->getMessage(),
41
  ];
42
  }
43
  }
@@ -47,12 +61,18 @@
47
  $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
48
  try {
49
  if (!extension_loaded('imagick') || !class_exists('Imagick')) {
50
- throw new \Exception('Server configuration: Imagick module is not available with this PHP installation.');
 
 
51
  } else if (!$image = new \Imagick($path)) {
52
- throw new \Exception(sprintf('"%s" is not a valid image file.', $path));
 
 
53
  }
54
  if (!isset($image)) {
55
- throw new \Exception(sprintf('Unsupported extension "%s" for file "%s"', $extension, $path));
 
 
56
  }
57
 
58
  return [
@@ -61,8 +81,9 @@
61
  ];
62
  } catch (\Exception $e) {
63
  return [
64
- 'success' => false,
65
- 'message' => $e->getMessage(),
 
66
  ];
67
  }
68
  }
@@ -72,9 +93,13 @@
72
  try {
73
  $output = (new Directory())->getPath($path, true);
74
  if (!$output) {
75
- throw new \Exception(sprintf('An error occurred creating destination directory for "%s" file.', $path));
 
 
76
  } else if (!in_array('WEBP', $image->queryFormats())) {
77
- throw new \Exception('Server configuration: Imagick does not support WebP format.');
 
 
78
  }
79
 
80
  $image->setImageFormat('WEBP');
@@ -86,7 +111,9 @@
86
 
87
  $success = file_put_contents($output, $blob);
88
  if (!$success) {
89
- throw new \Exception('Error occurred while converting image.');
 
 
90
  }
91
  do_action('webpc_convert_after', $output, $path);
92
 
@@ -101,8 +128,9 @@
101
  ];
102
  } catch (\Exception $e) {
103
  return [
104
- 'success' => false,
105
- 'message' => $e->getMessage(),
 
106
  ];
107
  }
108
 
17
 
18
  try {
19
  $status = (new Server())->checkIfFileExists($path);
20
+ if ($status !== true) {
21
+ $e = new \Exception($status);
22
+ $e->status = 'file_unreadable';
23
+ throw $e;
24
+ }
25
 
26
  $response = $this->createImage($path);
27
+ if (!$response['success']) {
28
+ $e = new \Exception($response['message']);
29
+ $e->status = isset($response['error_code']) ? $response['error_code'] : '';
30
+ throw $e;
31
+ } else {
32
+ $image = $response['data'];
33
+ }
34
 
35
  $image = apply_filters('webpc_imagick_before_saving', $image, $path);
36
  $response = $this->convertToWebp($image, $path, $settings);
37
+ if (!$response['success']) {
38
+ $e = new \Exception($response['message']);
39
+ $e->status = isset($response['error_code']) ? $response['error_code'] : '';
40
+ throw $e;
41
+ } else {
42
+ return [
43
+ 'success' => true,
44
+ 'data' => $response['data'],
45
+ ];
46
+ }
47
  } catch (\Exception $e) {
48
  if (in_array('debug_enabled', $settings['features'])) {
49
  error_log(sprintf('WebP Converter for Media: %s', $e->getMessage()));
51
 
52
  return [
53
  'success' => false,
54
+ 'message' => apply_filters('webpc_convert_error', $e->getMessage(), $e->status),
55
  ];
56
  }
57
  }
61
  $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
62
  try {
63
  if (!extension_loaded('imagick') || !class_exists('Imagick')) {
64
+ $e = new \Exception('Server configuration: Imagick module is not available with this PHP installation.');
65
+ $e->status = 'server_configuration';
66
+ throw $e;
67
  } else if (!$image = new \Imagick($path)) {
68
+ $e = new \Exception(sprintf('"%s" is not a valid image file.', $path));
69
+ $e->status = 'invalid_image';
70
+ throw $e;
71
  }
72
  if (!isset($image)) {
73
+ $e = new \Exception(sprintf('Unsupported extension "%s" for file "%s"', $extension, $path));
74
+ $e->status = 'unsupported_extension';
75
+ throw $e;
76
  }
77
 
78
  return [
81
  ];
82
  } catch (\Exception $e) {
83
  return [
84
+ 'success' => false,
85
+ 'message' => $e->getMessage(),
86
+ 'error_code' => (isset($e->status)) ? $e->status : '',
87
  ];
88
  }
89
  }
93
  try {
94
  $output = (new Directory())->getPath($path, true);
95
  if (!$output) {
96
+ $e = new \Exception(sprintf('An error occurred creating destination directory for "%s" file.', $path));
97
+ $e->status = 'output_path';
98
+ throw $e;
99
  } else if (!in_array('WEBP', $image->queryFormats())) {
100
+ $e = new \Exception('Server configuration: Imagick does not support WebP format.');
101
+ $e->status = 'server_configuration';
102
+ throw $e;
103
  }
104
 
105
  $image->setImageFormat('WEBP');
111
 
112
  $success = file_put_contents($output, $blob);
113
  if (!$success) {
114
+ $e = new \Exception('Error occurred while converting image.');
115
+ $e->status = 'convert_error';
116
+ throw $e;
117
  }
118
  do_action('webpc_convert_after', $output, $path);
119
 
128
  ];
129
  } catch (\Exception $e) {
130
  return [
131
+ 'success' => false,
132
+ 'message' => $e->getMessage(),
133
+ 'error_code' => (isset($e->status)) ? $e->status : '',
134
  ];
135
  }
136
 
app/Regenerate/Regenerate.php CHANGED
@@ -31,9 +31,10 @@
31
  $sizeAfter += $response['data']['size']['after'];
32
  }
33
  }
 
34
 
35
  return [
36
- 'errors' => $errors,
37
  'size' => [
38
  'before' => $sizeBefore,
39
  'after' => $sizeAfter,
31
  $sizeAfter += $response['data']['size']['after'];
32
  }
33
  }
34
+ $errors = array_filter($errors);
35
 
36
  return [
37
+ 'errors' => apply_filters('webpc_convert_errors', $errors),
38
  'size' => [
39
  'before' => $sizeBefore,
40
  'after' => $sizeAfter,
app/Regenerate/Skip.php CHANGED
@@ -8,14 +8,14 @@
8
  {
9
  public function __construct()
10
  {
11
- add_filter('webpc_attachment_paths', [$this, 'skipExistsImages'], 10, 2);
12
  }
13
 
14
  /* ---
15
  Functions
16
  --- */
17
 
18
- public function skipExistsImages($paths, $skipExists = false)
19
  {
20
  if (!$skipExists) return $paths;
21
 
8
  {
9
  public function __construct()
10
  {
11
+ add_filter('webpc_files_paths', [$this, 'skipExistsImages'], 10, 2);
12
  }
13
 
14
  /* ---
15
  Functions
16
  --- */
17
 
18
+ public function skipExistsImages($paths, $skipExists = true)
19
  {
20
  if (!$skipExists) return $paths;
21
 
app/Settings/Errors.php CHANGED
@@ -183,7 +183,7 @@
183
  $uploads = wp_upload_dir();
184
  $sourceFile = apply_filters('webpc_uploads_path', []) . self::PATH_OUTPUT_FILE_PNG;
185
 
186
- do_action('webpc_convert_paths', apply_filters('webpc_attachment_paths', [
187
  $sourceFile,
188
  ], true));
189
 
@@ -198,7 +198,7 @@
198
  $uploads = wp_upload_dir();
199
  $sourceFile = apply_filters('webpc_uploads_path', []) . self::PATH_OUTPUT_FILE_PNG2;
200
 
201
- do_action('webpc_convert_paths', apply_filters('webpc_attachment_paths', [
202
  $sourceFile,
203
  ], true));
204
 
183
  $uploads = wp_upload_dir();
184
  $sourceFile = apply_filters('webpc_uploads_path', []) . self::PATH_OUTPUT_FILE_PNG;
185
 
186
+ do_action('webpc_convert_paths', apply_filters('webpc_files_paths', [
187
  $sourceFile,
188
  ], true));
189
 
198
  $uploads = wp_upload_dir();
199
  $sourceFile = apply_filters('webpc_uploads_path', []) . self::PATH_OUTPUT_FILE_PNG2;
200
 
201
+ do_action('webpc_convert_paths', apply_filters('webpc_files_paths', [
202
  $sourceFile,
203
  ], true));
204
 
readme.txt CHANGED
@@ -1,6 +1,6 @@
1
  === WebP Converter for Media ===
2
  Contributors: mateuszgbiorczyk
3
- Donate link: https://ko-fi.com/gbiorczyk/
4
  Tags: convert webp, webp, optimize images, images, webp converter, performance, optimisation
5
  Requires at least: 5.0
6
  Tested up to: 5.5
@@ -51,7 +51,7 @@ Raise your website to a new level now! Install the plugin and enjoy the website
51
 
52
  We spend hours working on the development of this plugin. Technical support also requires a lot of time, but we do it because we want to offer you the best plugin. We enjoy every new plugin installation.
53
 
54
- If you would like to appreciate it, you can [provide us a coffee](https://ko-fi.com/gbiorczyk/). **If every user bought at least one, we could work on the plugin 24 hours a day!**
55
 
56
  #### Please also read the FAQ below. Thank you for being with us!
57
 
@@ -321,6 +321,14 @@ An alternative method is to manually start converting the selected attachment by
321
 
322
  In addition, you can edit the list of files that will be converted. For example, to add some to the exceptions. To do this, use the following filter, which by default returns a list of all paths:
323
 
 
 
 
 
 
 
 
 
324
  `add_filter('webpc_attachment_paths', function($paths, $attachmentId) {
325
  return $paths;
326
  }, 10, 2);`
@@ -470,7 +478,7 @@ And the following code **at the beginning of .htaccess file** in the `/wp-conten
470
 
471
  Yes. The plugin is completely free.
472
 
473
- However, working on plugins and technical support requires many hours of work. If you want to appreciate it, you can [provide us a coffee](https://ko-fi.com/gbiorczyk/). Thanks everyone!
474
 
475
  Thank you for all the ratings and reviews.
476
 
@@ -485,6 +493,11 @@ This is all very important to us and allows us to do even better things for you!
485
 
486
  == Changelog ==
487
 
 
 
 
 
 
488
  = 1.4.6 (2020-10-23) =
489
  * `[Fixed]` Error detection of non-working redirects without .png as supported file extension
490
 
1
  === WebP Converter for Media ===
2
  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: 5.0
6
  Tested up to: 5.5
51
 
52
  We spend hours working on the development of this plugin. Technical support also requires a lot of time, but we do it because we want to offer you the best plugin. We enjoy every new plugin installation.
53
 
54
+ If you would like to appreciate it, you can [provide us a coffee](https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=readme-content). **If every user bought at least one, we could work on the plugin 24 hours a day!**
55
 
56
  #### Please also read the FAQ below. Thank you for being with us!
57
 
321
 
322
  In addition, you can edit the list of files that will be converted. For example, to add some to the exceptions. To do this, use the following filter, which by default returns a list of all paths:
323
 
324
+ `add_filter('webpc_files_paths', function($paths, $skipExists) {
325
+ return $paths;
326
+ }, 10, 2);`
327
+
328
+ Argument `$paths` is array of absolute server paths and `$skipExists` means whether to skip converted images.
329
+
330
+ You can also modify the list of image paths for an attachment, e.g. to exclude one image size. To do this, use the following filter:
331
+
332
  `add_filter('webpc_attachment_paths', function($paths, $attachmentId) {
333
  return $paths;
334
  }, 10, 2);`
478
 
479
  Yes. The plugin is completely free.
480
 
481
+ However, working on plugins and technical support requires many hours of work. If you want to appreciate it, you can [provide us a coffee](https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=readme-faq). Thanks everyone!
482
 
483
  Thank you for all the ratings and reviews.
484
 
493
 
494
  == Changelog ==
495
 
496
+ = 1.5.0 (2020-10-28) =
497
+ * `[Added]` Filter `webpc_files_paths` to modify paths of images to be converted
498
+ * `[Added]` Filter `webpc_convert_error` to management of errors content displayed during conversion
499
+ * `[Added]` Filter `webpc_convert_errors` to management of errors displayed during conversion
500
+
501
  = 1.4.6 (2020-10-23) =
502
  * `[Fixed]` Error detection of non-working redirects without .png as supported file extension
503
 
resources/components/notices/thanks.php CHANGED
@@ -19,7 +19,7 @@
19
  class="webpContent__button webpButton webpButton--green">
20
  <?= __('Add review', 'webp-converter-for-media'); ?>
21
  </a>
22
- <a href="https://ko-fi.com/gbiorczyk/" target="_blank"
23
  class="webpContent__button webpButton webpButton--green dashicons-heart">
24
  <?= __('Provide us a coffee', 'webp-converter-for-media'); ?>
25
  </a>
19
  class="webpContent__button webpButton webpButton--green">
20
  <?= __('Add review', 'webp-converter-for-media'); ?>
21
  </a>
22
+ <a href="https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=notice-thanks" target="_blank"
23
  class="webpContent__button webpButton webpButton--green dashicons-heart">
24
  <?= __('Provide us a coffee', 'webp-converter-for-media'); ?>
25
  </a>
resources/components/widgets/donate.php CHANGED
@@ -7,7 +7,7 @@
7
  <?= __('However, working on plugins and technical support requires many hours of work. If you want to appreciate it, you can provide us a coffee. Thanks everyone!', 'webp-converter-for-media'); ?>
8
  </p>
9
  <p class="center">
10
- <a href="https://ko-fi.com/gbiorczyk/" target="_blank" class="webpButton webpButton--blue dashicons-heart">
11
  <?= __('Provide us a coffee', 'webp-converter-for-media'); ?>
12
  </a>
13
  </p>
7
  <?= __('However, working on plugins and technical support requires many hours of work. If you want to appreciate it, you can provide us a coffee. Thanks everyone!', 'webp-converter-for-media'); ?>
8
  </p>
9
  <p class="center">
10
+ <a href="https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=widget-donate" target="_blank" class="webpButton webpButton--blue dashicons-heart">
11
  <?= __('Provide us a coffee', 'webp-converter-for-media'); ?>
12
  </a>
13
  </p>
resources/components/widgets/regenerate.php CHANGED
@@ -46,7 +46,7 @@
46
  <div class="webpPopup__content">
47
  <p><?= __('Hi, I\'m Mateusz! I\'m glad you managed to reduce the weight of your website. If you would like to support me in developing this plugin, I will be very grateful to you!', 'webp-converter-for-media'); ?></p>
48
  <p>
49
- <a href="https://ko-fi.com/gbiorczyk/" target="_blank" class="webpButton webpButton--blue dashicons-coffee">
50
  <?= __('Provide me a coffee', 'webp-converter-for-media'); ?>
51
  </a>
52
  </p>
46
  <div class="webpPopup__content">
47
  <p><?= __('Hi, I\'m Mateusz! I\'m glad you managed to reduce the weight of your website. If you would like to support me in developing this plugin, I will be very grateful to you!', 'webp-converter-for-media'); ?></p>
48
  <p>
49
+ <a href="https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=notice-regenerate" target="_blank" class="webpButton webpButton--blue dashicons-coffee">
50
  <?= __('Provide me a coffee', 'webp-converter-for-media'); ?>
51
  </a>
52
  </p>
webp-converter-for-media.php CHANGED
@@ -3,13 +3,13 @@
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: 1.4.6
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter-for-media
10
  */
11
 
12
- define('WEBPC_VERSION', '1.4.6');
13
  define('WEBPC_FILE', __FILE__);
14
  define('WEBPC_NAME', plugin_basename(__FILE__));
15
  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: 1.5.0
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter-for-media
10
  */
11
 
12
+ define('WEBPC_VERSION', '1.5.0');
13
  define('WEBPC_FILE', __FILE__);
14
  define('WEBPC_NAME', plugin_basename(__FILE__));
15
  define('WEBPC_PATH', plugin_dir_path(__FILE__));