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

Modern Image Format return wrong size in picture element #1882

Open
1ucay opened this issue Feb 20, 2025 · 0 comments
Open

Modern Image Format return wrong size in picture element #1882

1ucay opened this issue Feb 20, 2025 · 0 comments
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Bug An existing feature is broken

Comments

@1ucay
Copy link

1ucay commented Feb 20, 2025

Hi, in picture element I have wrong AVIF image with resolution 768x768px.

How to reproduce

  1. Add to php
    add_image_size( 'square', 768, 768, true );
    add_filter( 'pre_option_medium_size_h', function() { return '768'; } );
    add_filter( 'pre_option_medium_size_w', function() { return '512'; } );
    add_filter( 'pre_option_medium_crop', function() { return array( 'center', 'center' ); } );
  1. Upload image to Media Library
  2. in template call wp_get_attachment_image( $post_thumbnail_id, 'medium', false );
  3. give me WRONG size in SOURCE element =>
    <picture>
        <source data-sizes="auto, (max-width: 768px) 100vw, 768px" data-srcset="gku6acxnr_a-768x768-jpg.avif 768w, gku6acxnr_a-1152x768-jpg.avif 1152w, gku6acxnr_a-1536x1024-jpg.avif 1536w, gku6acxnr_a-150x100-jpg.avif 150w, gku6acxnr_a-jpg.avif 1600w" type="image/avif"  >
        <img data-sizes="auto, (max-width: 768px) 100vw, 768px" data-src="gku6acxnr_a-768x512.jpg" data-srcset="gku6acxnr_a-768x512.jpg 768w, gku6acxnr_a-1152x768.jpg 1152w, gku6acxnr_a-1536x1024.jpg 1536w, gku6acxnr_a-150x100.jpg 150w, gku6acxnr_a.jpg 1600w" width="768" height="512" src="//:0" class="lazyload" alt="gku6acxnr a" decoding="async" loading="lazy"   data-has-transparency="false" data-dominant-color="9b6e44" style="--dominant-color: #9b6e44;" />
    </picture>
  1. In function webp_uploads_wrap_image_in_picture() I have array size_array =>
    print_r( $size_array );
    [image/jpeg] => Array
        (
            [w] => Array
                (
                    [1600] => Array
                        (
                            [file] => gku6acxnr_a.jpg
                            [filesize] => 346046
                        )

                    [768] => Array
                        (
                            [file] => gku6acxnr_a-768x768.jpg
                            [filesize] => 90049
                        )

                    [150] => Array
                        (
                            [file] => gku6acxnr_a-150x100.jpg
                            [filesize] => 6883
                        )

                    [1152] => Array
                        (
                            [file] => gku6acxnr_a-1152x768.jpg
                            [filesize] => 126075
                        )

                    [1536] => Array
                        (
                            [file] => gku6acxnr_a-1536x1024.jpg
                            [filesize] => 216081
                        )

                    [384] => Array
                        (
                            [file] => gku6acxnr_a-384x384.jpg
                            [filesize] => 29420
                        )

                )

            [h] => Array
                (
                    [1067] => Array
                        (
                            [file] => gku6acxnr_a.jpg
                            [filesize] => 346046
                        )

                    [512] => Array
                        (
                            [file] => gku6acxnr_a-768x512.jpg
                            [filesize] => 62979
                        )

                    [150] => Array
                        (
                            [file] => gku6acxnr_a-150x150.jpg
                            [filesize] => 8625
                        )

                    [768] => Array
                        (
                            [file] => gku6acxnr_a-768x768.jpg
                            [filesize] => 90049
                        )

                    [1024] => Array
                        (
                            [file] => gku6acxnr_a-1536x1024.jpg
                            [filesize] => 216081
                        )

                    [384] => Array
                        (
                            [file] => gku6acxnr_a-384x384.jpg
                            [filesize] => 29420
                        )

                    [100] => Array
                        (
                            [file] => gku6acxnr_a-150x100.jpg
                            [filesize] => 6883
                        )

                )

        )

    [image/avif] => Array
        (
            [w] => Array
                (
                    [1600] => Array
                        (
                            [file] => gku6acxnr_a-jpg.avif
                            [filesize] => 262685
                        )

                    [768] => Array
                        (
                            [file] => gku6acxnr_a-768x768-jpg.avif
                            [filesize] => 75746
                        )

                    [150] => Array
                        (
                            [file] => gku6acxnr_a-150x100-jpg.avif
                            [filesize] => 4278
                        )

                    [1152] => Array
                        (
                            [file] => gku6acxnr_a-1152x768-jpg.avif
                            [filesize] => 104232
                        )

                    [1536] => Array
                        (
                            [file] => gku6acxnr_a-1536x1024-jpg.avif
                            [filesize] => 184244
                        )

                    [384] => Array
                        (
                            [file] => gku6acxnr_a-384x384-jpg.avif
                            [filesize] => 24190
                        )

                )

            [h] => Array
                (
                    [1067] => Array
                        (
                            [file] => gku6acxnr_a-jpg.avif
                            [filesize] => 262685
                        )

                    [512] => Array
                        (
                            [file] => gku6acxnr_a-768x512-jpg.avif
                            [filesize] => 49628
                        )

                    [150] => Array
                        (
                            [file] => gku6acxnr_a-150x150-jpg.avif
                            [filesize] => 6105
                        )

                    [768] => Array
                        (
                            [file] => gku6acxnr_a-768x768-jpg.avif
                            [filesize] => 75746
                        )

                    [1024] => Array
                        (
                            [file] => gku6acxnr_a-1536x1024-jpg.avif
                            [filesize] => 184244
                        )

                    [384] => Array
                        (
                            [file] => gku6acxnr_a-384x384-jpg.avif
                            [filesize] => 24190
                        )

                    [100] => Array
                        (
                            [file] => gku6acxnr_a-150x100-jpg.avif
                            [filesize] => 4278
                        )

                )
        )
@1ucay 1ucay added the [Type] Bug An existing feature is broken label Feb 20, 2025
@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2025 Feb 20, 2025
@westonruter westonruter added the [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) label Feb 21, 2025
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) [Type] Bug An existing feature is broken
Projects
Status: Not Started/Backlog 📆
Development

No branches or pull requests

2 participants