Closed Bug 2038497 Opened 3 months ago Closed 3 months ago

image width and height is wrong

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 152
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: david.vantyghem, Unassigned)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0

Steps to reproduce:

Display https://infolib.re/blog/recuperer-un-programme-dans-un-automate-telemecanique/

Actual results:

With new version 150.0.2, some images are displayed with a good size but others are now displayed with a wrong size, there's another regression after solving https://bugzilla.mozilla.org/show_bug.cgi?id=2035156.
By example, this image https://infolib.re/blog/wp-content/uploads/2023/12/Cable-PC-Terminal-Magelis.jpeg is displayed wrongly in https://infolib.re/blog/recuperer-un-programme-dans-un-automate-telemecanique/

Expected results:

The image should be displayed like in https://infolib.re/blog/wp-content/uploads/2023/12/Cable-PC-Terminal-Magelis.jpeg

This image is displayed too big since 150.0.2 version.

The image is now showing the same size in Firefox 150.0.2 as it does in Google Chrome and Microsoft Edge.

I don't use Chrome and Edge. I use Firefox. The image was displayed at a good size by Firefox before 150.0.2 version, now it's too huge and not at the size chosen in WordPress.

The image size chosen in WordPress.

What is strange is that only this image seems to be badly displayed.

Hi, thanks for filing.

So, we started supporting contain-sizes="auto" for <img> as of 152, as part of bug 2035864 - This is a standards-conforming feature, so this is (Unfortunately for this case) expected.

I see that for the badly sized photo, there is sizes="auto, (max-width: 335px) 100vw, 335px". Since sizes=auto is there, it triggers size containment, and we look at the contain-intrinsic-size for the image to figure out what the image size is supposed to be. The site specifies:

img:is([sizes="auto" i], [sizes^="auto," i]) {
  contain-intrinsic-size: 3000px 1500px;
}

So the site tells Firefox that the image is supposed to be that big, so we end up sizing it as closely to it as possible, which causes the image to be zoomed to the width of the container.

I see that the photo right above the badly displayed one in fact doesn't have auto, and it sidesteps this problem. A bunch of other pictures have auto in them, but they end up being sized closely to the intended size, so they don't get zoomed in.

So I think the solution here is to remove any occurrence of auto in the sizes attribute for <img>.

Flags: needinfo?(david.vantyghem)

I think sizes="auto" is added by WordPress because I can only edit this code:

<a href="https://infolib.re/blog/wp-content/uploads/2023/12/Cable-PC-Terminal-Magelis.jpeg"><img class="aligncenter size-full wp-image-12162" src="https://infolib.re/blog/wp-content/uploads/2023/12/Cable-PC-Terminal-Magelis.jpeg" alt="Brochage du câble PC - Terminal Magelis" width="335" height="538" /></a>

I found this WordPress bug report, maybe it's related?
https://core.trac.wordpress.org/ticket/62515#comment:35

Flags: needinfo?(david.vantyghem)

Yes, that seems like the exact problem.

Yeah this seems invalid, we're behaving correctly, and the same as other browsers. Seems this must be fixed on Wordpress' side.

Status: UNCONFIRMED → RESOLVED
Closed: 3 months ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: