• Resolved azertix80

    (@azertix80)


    Hi

    Would it be possible to exclude specific file if they contain a keyword, but not especially as a suffix ?

    In the FAQ the filter uses a suffix. For exemple “myfile-skipwebp.png”. But what about “skipwebp-file.png” or “file-skipwebp-file.png” ?

    Can the filter be modified in this way ?

    Thanks in advance for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @azertix80,

    Thank you for your message.

    Of course. For this purpose, I have prepared the following filter for you:

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

    If you encounter any problems, please, feel free to reach out to me.

    Best,
    Mateusz

    Thread Starter azertix80

    (@azertix80)

    Great, thank you !

    • This reply was modified 2 years, 2 months ago by azertix80.
    • This reply was modified 2 years, 2 months ago by azertix80.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude files by keyword’ is closed to new replies.