Use WebP-aware image methods in product detail gallery#71
Open
Use WebP-aware image methods in product detail gallery#71
Conversation
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.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getMasterZoomPictureUrl()which callsConfig::getPictureUrl()directly, bypassingPictureHandlerand its WebP URL logicblConvertImagesToWebPis enabledgetimg.phpReplaced with the appropriate WebP-aware methods that route through
PictureHandler::getProductPicUrl():product_no_zoomgetMasterZoomPictureUrlgetPictureUrlproduct_hover_zoomgetMasterZoomPictureUrlgetZoomPictureUrlproduct_magnifier_lensgetMasterZoomPictureUrlgetZoomPictureUrlproduct_modal_zoom(slider)getMasterZoomPictureUrlgetPictureUrlproduct_modal_zoom(modal)getMasterZoomPictureUrlgetZoomPictureUrlmorepics(data-zoom-url)getMasterZoomPictureUrlgetZoomPictureUrlNote:
getZoomPictureUrl()already existed in Article.php but was unused by any template. It uses the configurablesZoomImageSizeparameter and is fully WebP-aware.Related: OXDEV-9008 solved this differently on b-8.0.x via a new MediaItem API.
Test plan
/generated/(not/master/)blConvertImagesToWebPenabled: image URLs end in.webpproductZoomTypeunset): product image displays correctlyaDetailImageSizes/sZoomImageSize