| @@ -25,9 +25,25 @@ | ||
| 25 | 25 | if ( 'image' !== $type ) { |
| 26 | 26 | $mimes['pdf'] = 'application/pdf'; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return $mimes; | |
| 29 | + /** | |
| 30 | + * Filter the mime types which could be optimized by Imagify. | |
| 31 | + * | |
| 32 | + * @since 2.3.1 | |
| 33 | + * | |
| 34 | + * @param array $mimes The mime types, as extension => mime type pairs. | |
| 35 | + */ | |
| 36 | + $mimes = wpm_apply_filters_typed( 'array', 'imagify_get_mime_types', $mimes ); | |
| 37 | + | |
| 38 | + // Keep only well-formed extension => mime type pairs. | |
| 39 | + return array_filter( | |
| 40 | + $mimes, | |
| 41 | + function ( $mime, $ext ) { | |
| 42 | + return is_string( $ext ) && '' !== $ext && is_string( $mime ) && preg_match( '@^[a-z-]+/[a-z0-9.+-]+$@', $mime ); | |
| 43 | + }, | |
| 44 | + ARRAY_FILTER_USE_BOTH | |
| 45 | + ); | |
| 30 | 46 | } |
| 31 | 47 | |
| 32 | 48 | /** |
| 33 | 49 | * Tell if an attachment has a supported mime type. |