Skip to content

Comments

Use WebP-aware image methods in product detail gallery#71

Open
SvenBrunk wants to merge 2 commits intob-7.5.xfrom
feature/webp-zoom-images
Open

Use WebP-aware image methods in product detail gallery#71
SvenBrunk wants to merge 2 commits intob-7.5.xfrom
feature/webp-zoom-images

Conversation

@SvenBrunk
Copy link
Contributor

Summary

  • All gallery zoom templates and morepics used getMasterZoomPictureUrl() which calls Config::getPictureUrl() directly, bypassing PictureHandler and its WebP URL logic
  • This served unscaled master images (original resolution PNG/JPG) without WebP conversion, even when blConvertImagesToWebP is enabled
  • Master images are served directly by Apache without going through getimg.php

Replaced with the appropriate WebP-aware methods that route through PictureHandler::getProductPicUrl():

Template Before After Rationale
product_no_zoom getMasterZoomPictureUrl getPictureUrl Display only, no zoom
product_hover_zoom getMasterZoomPictureUrl getZoomPictureUrl JS zooms via CSS transform on same img
product_magnifier_lens getMasterZoomPictureUrl getZoomPictureUrl JS copies img.src to magnifier result
product_modal_zoom (slider) getMasterZoomPictureUrl getPictureUrl Preview before opening modal
product_modal_zoom (modal) getMasterZoomPictureUrl getZoomPictureUrl Enlarged view inside modal
morepics (data-zoom-url) getMasterZoomPictureUrl getZoomPictureUrl Zoom URL for JS

Note: getZoomPictureUrl() already existed in Article.php but was unused by any template. It uses the configurable sZoomImageSize parameter and is fully WebP-aware.

Related: OXDEV-9008 solved this differently on b-8.0.x via a new MediaItem API.

Test plan

  • Product detail page: main image loads from /generated/ (not /master/)
  • With blConvertImagesToWebP enabled: image URLs end in .webp
  • No zoom (productZoomType unset): product image displays correctly
  • Hover zoom: zoom effect works on mouseover
  • Magnifier lens: lens and result display correctly
  • Modal zoom: click opens modal, carousel works, images are larger resolution
  • Morepics: clicking thumbnails switches the main image
  • Image sizes match configured aDetailImageSizes / sZoomImageSize

All gallery zoom templates and morepics used getMasterZoomPictureUrl()
which bypasses PictureHandler and serves unscaled master images without
WebP conversion, even when blConvertImagesToWebP is enabled.

Replace with the appropriate WebP-aware methods:
- product_no_zoom: getPictureUrl() (detail image size, no zoom needed)
- product_hover_zoom: getZoomPictureUrl() (JS zooms via CSS transform)
- product_magnifier_lens: getZoomPictureUrl() (JS copies src to lens)
- product_modal_zoom: getPictureUrl() for slider, getZoomPictureUrl()
  for modal carousel
- morepics: getZoomPictureUrl() for data-zoom-url attribute

Both getPictureUrl() and getZoomPictureUrl() route through
PictureHandler::getProductPicUrl() which appends .webp when
blConvertImagesToWebP is enabled and serves scaled images from
/generated/ via getimg.php instead of raw master files.
The sPictureName and aPictureInfo variables were computed in every
loop iteration via getPictureFieldValue + getMasterPicturePath +
getimagesize, but never used in the rendered output. In morepics,
the resulting data-width/data-height attributes were set but never
read by any JavaScript. Remove the dead code to avoid unnecessary
filesystem access on every product detail page load.
@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