You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comments: let the web view size gallery images instead of the main screen #26252
Gallery images in comments are sized for one screen when the comment is synced, not for the view that shows them. Let the web view that displays the comment pick the size instead.
What happens today
CommentService formats comment content when it syncs comments, and saves the result to Core Data.
As part of that, RichContentFormatter.resizeGalleryImageURL rewrites the src of each gallery image (<img data-orig-file=…>) to one fixed size.
The saved HTML depends on the device and window size that synced it, not the one that shows it.
The size is the whole screen, so on iPad, or in a narrow window, it's larger than the space the image is shown in.
UIScreen.main assumes a single, fixed display. The code has a TODO: Modernization comment for this.
Suggested fix
Comments are shown as HTML in a web view (CommentWebView), and the web view already knows the layout width and the display scale.
In resizeGalleryImageURL, add a srcset with a few Photon widths (for example 400, 800, 1200 and 2048 px) and sizes="100vw", instead of setting one size in src. Keep src as a fallback.
WebKit then picks the right image when the comment is displayed, and picks again if the window moves to another display.
Drop the bounds and traitCollection parameters from formatContentString and resizeGalleryImageURL. CommentService is the only caller.
Things to check
Find or create a comment with a gallery image, and confirm it goes through this path.
Private sites use WPImageURLHelper instead of Photon. Check it can produce width-only URLs.
Gallery images with an existing srcset attribute.
Not affected
The Reader post view formats content separately and isn't part of this.
Activity
dangermattic commentedon Oct 27, 2026
Thanks for reporting! 👍
Stop reading the current trait collection when sizing images
Cherry-pick the iPhone Duo fixes into 27.4 (#26290)
Size pixels from the view's display scale, not the main screen (wordp…
Merge release/27.4 into trunk (wordpress-mobile#26297)