WEBP Converter for media exclude

Wykluczanie poszczególnych plików z konwersji na webp. Gdy konwersja skutkuje nieodpowiednią jakością.

Do nazwy wgrywanego pliku graficznego który, ma być pominięty, należy dodać końcówkę „-skipwebp”.

To exclude selected files use the following filter *(in this case with the suffix "-skipwebp" in a filename, e.g. image-skipwebp.png)*:

`add_filter( 'webpc_supported_source_file', function( bool $status, string $file_name, string $server_path ): bool {
    $excluded_suffix = '-skipwebp';
    if ( strpos( $file_name, $excluded_suffix . '.' ) !== false ) {
        return false;
    }
    return $status;
}, 10, 3 );`

Argument `$server_path` is the absolute server path to a directory or file. Inside the filters, you can apply more complicated rules as needed.

Filters run before images are converted - they no longer support converted images. You have to delete them manually if they should not be converted.

Należy pamiętać, że w przypadku dodania obrazka klasycznie przez cms, wordpress dorobi inne formaty obrazka i doda do nazw własne końcówki z rozdzielczością, które wykorzysta jako currentsource. Więc by wykluczenie działało poprawnie, trzeba dodać obrazek jako własny html.

Dodaj komentarz