Hi @lawriem1,
Thank you for your message.
The plugin supports images from the following directories:
/wp-content/uploads
/wp-content/plugins
/wp-content/themes
And your files are located in the /wp-content/gallery
directory, which is not supported.
@lawriem1 But I am happy to help you and show you how you can add support for /wp-content/gallery
directory to the plugin.
Add the following code to the functions.php file in your theme directory:
add_filter( 'webpc_get_options', function( $options ) {
foreach ( $options as $index => $option ) {
if ( $option['name'] !== 'dirs' ) {
continue;
}
$options[ $index ]['values']['gallery'] = '/gallery';
}
return $options;
}, 20, 1 );
add_filter( 'webpc_dir_name', function( $value, $directory ) {
if ( $directory !== 'gallery' ) {
return $value;
}
return 'wp-content/gallery';
}, 20, 2 );
Then a new directory will appear in the plugin in the “List of supported directories” section. Check this option and start converting all images.
Images added to the Media Library are automatically converted to WebP. This is not possible with your directory. Check the “Enable cron to automatically convert images from outside Media Library” option in the plugin settings. This will allow them to be converted automatically on a regular basis.
Did this solution help you?
Thank you for your quick reply.
Most of my images are delivered through the NextGEN Gallery on 10 of my websites so it is a shame that the associated directory is not supported.
I would imagine many people would be in the same boat as the NextGEN Gallery plugin is widely used (5th most popular plugin for WordPress).
Any plans to support it?
@lawriem1 Please read my second post above. I think it will help you.
Thanks Mateusz
Our messages crossed.
I will try your solution tomorrow (getting late here now) and let you know how I get on.
Thanks again for your prompt reply.
I added the code as instructed and the new gallery directory appeared in the list. I saved the changes and deleted the cache but the NextGEN images were still served as JPGs. Also the gallery didn’t work properly. Clicking on a thumbnail just opened that image with no way of going to the next image.
I then regenerated the images and flushed the cache again but just got the same result.
@lawriem1 Could you please send me the contents of the following files?
/.htaccess (root directory of WordPress)
/wp-content/.htaccess
I’m using the Pass Thru Image Loading mode, not via .htaccess
Because if I use the .htaccess version I get this error message.
WebP Converter for Media
Changes were successfully saved! Please flush cache if you use caching plugin or caching via hosting.
Server configuration error
Redirects on your server are not working. Check the correct configuration for you in the plugin FAQ. If your configuration is correct, it means that your server does not support redirects from the .htaccess file or requests to images are processed by your server bypassing Apache.
In this case, please contact your server administrator.
Also try changing option “Image loading mode” to a different one. Issues about rewrites can often be resolved by setting this option to “Pass Thru”. You can do this in plugin settings below. After changing settings, remember to flush cache if you use caching plugin or caching via hosting.
—
Error codes: rewrites_not_working
@lawriem1 Please send me a screenshot of the plugin settings.
OK. Where should I send it?
Please send me via e-mail – mateusz[at]gbiorczyk[dot]pl
.