Skip to content

Fix broken WebP picture element in product grid listing#70

Open
SvenBrunk wants to merge 2 commits intob-7.5.xfrom
fix/webp-image-handling
Open

Fix broken WebP picture element in product grid listing#70
SvenBrunk wants to merge 2 commits intob-7.5.xfrom
fix/webp-image-handling

Conversation

@SvenBrunk
Copy link
Contributor

Summary

  • The <picture> element in listitem_grid.html.twig incorrectly declared type="image/webp" while getMasterZoomPictureUrl(2) returned a PNG/JPG master URL that bypasses PictureHandler and its WebP URL logic entirely
  • The fallback <img> was a transparent 1x1 GIF, rendering nothing on mobile viewports (< 1024px)
  • Master images were served at original resolution into a 350x220 container, wasting bandwidth

Replaced with a simple <img> using getPictureUrl(2) which correctly routes through PictureHandler::getProductPicUrl(), serving scaled images from /generated/ with proper .webp suffix when blConvertImagesToWebP is enabled. Desktop-only visibility is handled via Bootstrap's d-none d-lg-block instead of the broken media query approach.

Note: This is a backport-style fix for OXID 7.x. The same issue was addressed differently on b-8.0.x via OXDEV-9008 using the new MediaItem API.

Test plan

  • Verify hover image still appears on desktop in category grid view
  • Inspect HTML: no type="image/webp", URL should point to /out/pictures/generated/ (not /master/)
  • With blConvertImagesToWebP enabled: URL should end in .webp
  • On mobile viewport: no invisible/broken image element from the hover picture

The <picture> element incorrectly declared type="image/webp" while
getMasterZoomPictureUrl() returned a PNG/JPG master URL that bypasses
PictureHandler and its WebP URL logic entirely. The fallback <img> was
a transparent 1x1 GIF, rendering nothing on mobile viewports.

Replace with a simple <img> using getPictureUrl(2) which correctly
routes through PictureHandler::getProductPicUrl(), serving scaled
images from /generated/ with proper .webp suffix when enabled.
getPictureUrl(2) always returns a URL (including nopic fallback),
causing a cardboard box placeholder to appear on hover for products
without a second image. Use getMasterZoomPictureUrl(2) for the
condition check (returns false for nopic) while keeping getPictureUrl(2)
for the src (WebP pipeline).
@SvenBrunk
Copy link
Contributor Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant