Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,26 @@ public function set_up(): void {
$this->markTestSkipped( 'The Imagick PHP extension is not loaded.' );
}

add_filter(
'wp_image_editors',
static function ( array $editors ): array {
return array_filter(
$editors,
static function ( $editor ): bool {
return WP_Image_Editor_Imagick::class === $editor;
}
);
}
);
$required_formats = array( 'JPEG', 'PNG', 'GIF', 'WEBP' );
try {
$supported_formats = Imagick::queryFormats();
} catch ( Exception $exception ) {
$this->markTestSkipped( sprintf( 'Unable to query Imagick formats: %s', $exception->getMessage() ) );
}
$missing_formats = array_diff( $required_formats, $supported_formats );
if ( 0 === count( $missing_formats ) ) {
add_filter(
'wp_image_editors',
static function ( array $editors ): array {
return array_filter(
$editors,
static function ( $editor ): bool {
return WP_Image_Editor_Imagick::class === $editor;
}
);
}
);
}
}

/**
Expand Down
Loading