Hi @hliltd,
Thank you for your message.
In this arrangement, I suggest that you add suffix to all images that you would like to exclude from converting. For example, if the image is named my-image-01.jpg, before uploading the file to the media library, change its name to my-image-01-email.jpg.
When you use the -email
suffix, you can use the following filter to exclude files from converting to WebP (you can use a different suffix, but remember to change it in the filter code):
add_filter('webpc_attachment_paths', function($paths) {
$suffix = '-email';
foreach ($paths as $index => $path) {
if (!preg_match('/(.*?)' . $suffix . '((-(.*))?)\.(jpe?g|png|gif)/', basename($path))) continue;
unset($paths[$index]);
}
return $paths;
});
By adding a filter, you are not editing the plugin code because these changes were removed during the upgrade. Please add this code to the functions.php file (at the bottom) in your theme directory, eg.:
/wp-content/themes/my-theme/functions.php
Then try to upload the file containing suffix -email
to the media library. It will only be available in its original format and will not be converted to WebP.