Skip to content

Instantly share code, notes, and snippets.

@jbma
Created November 13, 2019 14:27
Show Gist options
  • Select an option

  • Save jbma/173d81d8af20fa3351d60a6e14212cc4 to your computer and use it in GitHub Desktop.

Select an option

Save jbma/173d81d8af20fa3351d60a6e14212cc4 to your computer and use it in GitHub Desktop.

Revisions

  1. jbma created this gist Nov 13, 2019.
    13 changes: 13 additions & 0 deletions webp-gif.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php

    function no_webp_for_gif( $response, $process, $file, $thumb_size, $optimization_level, $webp, $is_disabled ) {
    if ( ! $webp || $is_disabled || is_wp_error( $response ) ) {
    return $response;
    }
    if ( 'image/gif' !== $file->get_mime_type() ) {
    return $response;
    }
    return new \WP_Error( 'no_webp_for_gif', __( 'Webp version of gif is disabled by filter.' ) );
    }