Skip to content

Some webp images sizes are not calculated correctly (1px) #2468

Open

Description

@ligne13

Bug Description

Sometimes, webp images are displayed at 1x1 px. In the medla library and on the website. When I open the image URL in a new tab it is displayed correctly.

Image

The first image has width and height equal to 1px in the HTML:

Image

Additional Context

  • Wordpres Version : 6.9.4
  • PHP Version: 8.1.34
  • Plugin Version: Modern Image Formats 2.6.1

Activity

  1. moved this to Not Started/Backlog 📆 in WP Performance Ongoingon May 7, 2026
  2. westonruter commented on May 7, 2026

    @westonruter
    Member

    Can you share share the URL to the original JPEG which was resulted in this 1x1 pixel WebP?

  3. ligne13 commented on May 14, 2026

    @ligne13
    Author

    Here it is. Thank you.

    Image
  4. adamsilverstein commented on May 18, 2026

    @adamsilverstein
    Member

    Bug Description

    Sometimes, webp images are displayed at 1x1 px. In the medla library and on the website. When I open the image URL in a new tab it is displayed correctly.

    Hi @ligne13 thanks for the bug report.

    A few questions:

    • Does this happen every time you upload any jpeg, or only certain ones?
    • Can you disable all other plugins temporarily and still if the issue still occurs? we haven't had this reported before it might be a conflict with another plugin. If it is a conflict, please share a list of your plugins.
    • Can you describe the exact steps to reproduce please - are you uploading in the media library, or in a post?

    The first image has width and height equal to 1px in the HTML

    Only the first image?

  5. ligne13 commented on May 19, 2026

    @ligne13
    Author

    It happens randomly. I was not able to reproduce the bug with the same image. I trizd to upload from the library and from the block editor and it worked this time.

    The first image...

    I was just referring to the first image in the list in the screenshot of the Media library.

  6. MarcinDudekDev commented on Jun 4, 2026

    @MarcinDudekDev
    Contributor

    Thanks for the report and the sample image, @ligne13. A few notes that might help narrow this down — and one quick check that would tell us a lot.

    The "random / can't reproduce" detail is actually the important clue. A 1×1 image in the HTML and in the Media Library grid points at the stored attachment metadata (_wp_attachment_metadata), not the file itself — which lines up with the file opening fine in a new tab. The grid doesn't go through any <picture> rewriting, so if it also shows 1px, the bad dimensions are already saved in the DB. That reconciles "random": the corruption happens at upload time, intermittently. Once an attachment is written with bad dimensions it stays bad, but re-uploading creates a fresh attachment that usually processes cleanly — which is why the same image "worked the second time."

    One check that localizes the bug. For a known-bad attachment, could you dump its stored metadata?

    wp post meta get <attachment_id> _wp_attachment_metadata

    (or view it via Query Monitor). Two outcomes:

    • sizes[...]['width'] is literally 1 → the dimensions were corrupted when the metadata was generated (upload time).
    • Stored dimensions are correct but the HTML is still 1×1 → it's happening in the output path, and we should look at the image/<picture> rendering instead.

    Why literally 1 is interesting. Missing or zero dimensions usually render as 0 or get omitted — a literal 1 is a narrower fingerprint. It tends to come from a degenerate image resource (e.g. a failed decode falling back to a 1×1) or from getimagesize() / the image editor reading a file that wasn't fully flushed yet and returning just the header dimensions. That last one is inherently intermittent and is much more likely on hosts using object storage / CDN offload (e.g. S3), NFS/network filesystems, or aggressive opcache/stat caching — the original file is read for sub-size generation before it has finished being written, then finishes a moment later (which is why it looks fine afterwards).

    So a few questions that would help:

    • What is the result of the metadata dump above for a bad attachment?
    • Is the site using any media offload / S3 / CDN plugin, or a network/shared filesystem?
    • Roughly what is the PHP memory_limit, and does it correlate with large uploads or batch uploads (several at once)?
    • As @adamsilverstein asked — does it still happen with other plugins disabled? Concurrent writes to the same attachment from another plugin (thumbnail regeneration, image optimizers) during upload could also explain intermittent partial metadata.

    Happy to help dig further once we see whether the stored width is 1 or correct — that splits the problem cleanly.

  7. ligne13 commented on Jun 16, 2026

    @ligne13
    Author

    Hi @MarcinDudekDev ,
    sorry for the delay.
    I ran wp post meta get 96904 _wp_attachment_metadata and here is the result:

    array (
    'dominant_color' => '757863',
    'has_transparency' => false,
    'sources' =>
    array (
    'image/webp' =>
    array (
    'file' => 'Fondation-Royaumont-Olivier-Ouadah-cloitre-269-png.webp',
    'filesize' => 595090,
    ),
    ),
    )

    There is no sizes key.

    The site is not using any S3 / CDN or remote storage plugin.

    PHP memory limit is set to 512M.

    Thanks for the help.

  8. adamsilverstein commented on Jun 19, 2026

    @adamsilverstein
    Member

    Thanks for the additional data. It looks like the uploaded image isn't available when core tries to read the file size and the plugs aren't careful about the empty returned value. I'll work on a PR to guard against that.

    It happens randomly.

    This indicates some sort of race condition where the upload is happening while the server is not able to read the file size after the upload in wp_getimagesize, perhaps the disk write hasn't completed. If we can't guard against that, we can at least abort when we see it so you don't get an image showing up at 1x1.

  9. adamsilverstein commented on Aug 28, 2026

    @adamsilverstein
    Member

    This will hopefully be fixed by some recent fixes in clinet-side media landing in 7.1.1 for a related issue with image sizes metadata. Once this ships we can re-test to see if the bug persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ContributorDayIssues flagged as Contributor Day candidates.[Plugin] Modern Image FormatsFormerly WebP Uploads [slug: webp-uploads][Type] BugAn existing feature is broken

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions