WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 6 weeks ago

#54039 new enhancement

site health can probably do better job at detecting if imagick supports PDF

Reported by: mark-k Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Site Health Keywords:
Focuses: Cc:

Description

The current code is

if ( function_exists( 'exec' ) ) {
    $gs = exec( 'gs --version' );
    if ( empty( $gs ) ) {
.....

exec is probably disabled on many hosts which means the test will not run at all.

From looking at https://www.drupal.org/project/media_thumbnails/issues/3207465 it seems that imagick reports whether it supports PDF format as part of its phpinfo output. Maybe there is a direct API to get th information as well.

If this is not robust enough, maybe the test should try to generate an image from a test pdf file.

Change History (3)

#1 @nosilver4u
7 weeks ago

Indeed, one can use the queryFormats() method to check which file types are supported. We use this in EWWW IO for several mime types: https://github.com/nosilver4u/ewww-image-optimizer/blob/46fc90569822e4ef04cfaf792423911738d6dad9/common.php#L3246

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


6 weeks ago

#3 @antpb
6 weeks ago

  • Component changed from Media to Site Health

Moving this over to Site Health as I think it may need folks more familiar with the existing checks we have today.

Note: See TracTickets for help on using tickets.