Skip to content

Commit

Permalink
Add filter for nextgen image format #777
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Jan 17, 2024
1 parent 9302759 commit 72f7c6a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions inc/common/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,29 @@ function imagify_add_webp_type( $ext2type ) {
* @author Grégory Viguier
*/
add_filter( 'big_image_size_threshold', [ imagify_get_context( 'wp' ), 'get_resizing_threshold' ], IMAGIFY_INT_MAX );

/**
* Add filters to manage images formats that will be generated
*
* @param array $formats

Check notice on line 74 in inc/common/attachments.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/common/attachments.php#L74

Missing parameter comment
*
* @return array;
*/
function imagify_nextgen_images_format( array $formats ) {
//If no formats is passed, bail early and default to webp.

Check notice on line 79 in inc/common/attachments.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/common/attachments.php#L79

No space found before comment text; expected "// If no formats is passed, bail early and default to webp." but found "//If no formats is passed, bail early and default to webp."
if ( empty( $formats) ) {

Check notice on line 80 in inc/common/attachments.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/common/attachments.php#L80

Expected 1 spaces before closing parenthesis; 0 found
return ['webp'];
}

if ( isset( $formats['webp'], $formats['avif'] )
&& ( $formats['avif'] && $formats['webp'] )
) {
return ['avif', 'webp'];
}

return $formats;
}
/**
* Filter to get the image format to generate.
*/
add_filter( 'imagify_nextgen_images_formats', 'imagify_nextgen_images_format' );

0 comments on commit 72f7c6a

Please sign in to comment.