Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF thumbnails to WEBP/AVIF #1766

Open
1ucay opened this issue Dec 20, 2024 · 0 comments
Open

PDF thumbnails to WEBP/AVIF #1766

1ucay opened this issue Dec 20, 2024 · 0 comments
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads)

Comments

@1ucay
Copy link

1ucay commented Dec 20, 2024

Dear all,

if you upload PDF, in metadata sizes we have array with jpgs.

I tried fix with

add_filter( 'webp_uploads_upload_image_mime_transforms', 'core_webp_uploads_upload_image_mime_transforms', 9, 2 );
function core_webp_uploads_upload_image_mime_transforms( $default_transforms ) {

    $mimes = wp_get_mime_types();

    $output_format = webp_uploads_mime_type_supported( 'image/avif' ) ? webp_uploads_get_image_output_format() : 'webp';
    $transforms    = webp_uploads_is_fallback_enabled() ? array( 'image/jpeg', 'image/' . $output_format ) : array( 'image/' . $output_format );

    foreach( $mimes as $k => $v ) {
        if ( ! isset( $default_transforms[ $v ] ) )
            $default_transforms[ $v ] = $transforms;
    }

    return $default_transforms;
}

If you upload PSD with mime image/vnd.adobe.photoshop and genereate sizes with some custom code (imagemagick support PSD) like PDF does

add_filter( 'wp_generate_attachment_metadata', 'core_wp_generate_attachment_metadata', 9, 2 );

it working ok. I have nice jpg and avif in metadata.

But, different situation is with PDF mime application/pdf. It is blocked by helper.php line 145

$image_path = wp_get_original_image_path( $attachment_id );

and inside function is condition

  if ( ! wp_attachment_is_image( $attachment_id ) ) {

We dont have any filter skip this check, so PDF avif is not working. Best would be add filter to "wp_attachment_is" and override.

Im working on LibreOffice (exec soffice), audiowave (exec https://github.com/bbc/audiowaveform ) , PSD / AI (imagemagick) thumbnailer.
https://core.trac.wordpress.org/ticket/62712

@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2024 Dec 20, 2024
@westonruter westonruter added the [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads)
Projects
Status: Not Started/Backlog 📆
Development

No branches or pull requests

2 participants