Comments: let the web view size gallery images instead of the main screen

Abierto
#26,252 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
ios, swift
Área
mobile

Línea de trabajo

Start with RichContentFormatter.resizeGalleryImageURL and its caller, CommentService; trace how it rewrites gallery image src values and how WPImageURLHelper builds URLs for private sites. Check existing srcset handling and the CommentWebView display path. Done means the saved comment HTML lets WebKit choose gallery image widths, including on private sites and for images with an existing srcset.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

[Type] Tech Debt Comments

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.
  • That size comes from the main screen's bounds. After #26202 it uses a fixed 3x scale (UITraitCollection.largestDisplayScale), but it still reads UIScreen.main.bounds.

Why it's a problem

  • 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.

  1. 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.
  2. WebKit then picks the right image when the comment is displayed, and picks again if the window moves to another display.
  3. 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.

Lenguaje dominante
Swift
Estrellas
3.9k
Forks
1.2k
Merge medio
1 d 23 h
PR fusionados (30 d)
136

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de wordpress-mobile/WordPress-iOS

Todos los issues de wordpress-mobile/WordPress-iOS

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.