-
Notifications
You must be signed in to change notification settings - Fork 842
Slideshow: Fix image sizing when parent height is not set #46450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where slideshows stretch to the full parent container width on mobile devices when the parent ul element's height is not set. The fix adds a fallback to use a 16:9 aspect ratio when the image's natural dimensions are not available.
Key Changes:
- Added a check for valid
naturalWidthandnaturalHeightproperties before calculating aspect ratio - Falls back to a 16:9 aspect ratio when natural dimensions are unavailable or invalid
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| projects/plugins/jetpack/extensions/blocks/slideshow/swiper-callbacks.js | Adds validation for naturalWidth/naturalHeight and provides 16:9 fallback for aspect ratio calculation |
| projects/plugins/jetpack/changelog/fix-jetpack-slideshow-aspectRatio-fallback | Changelog entry documenting the bugfix |
projects/plugins/jetpack/changelog/fix-jetpack-slideshow-aspectRatio-fallback
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/slideshow/swiper-callbacks.js
Outdated
Show resolved
Hide resolved
…tRatio-fallback Co-authored-by: Copilot <[email protected]>
…llbacks.js Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
projects/plugins/jetpack/extensions/blocks/slideshow/swiper-callbacks.js
Show resolved
Hide resolved
projects/plugins/jetpack/extensions/blocks/slideshow/swiper-callbacks.js
Show resolved
Hide resolved
|
Testing this is proving difficult, primarily in terms of consistently replicating the issue in order to confirm changes fix it, and also that the site mentioned in the issue is Simple so testing the changes (proxied on mobile presumably) is not something I'm familiar with. I wonder if someone on the mobile team is able to reproduce the issue on mobile and confirm if the fix works for the site in question. I was able to confirm no changes to slideshow display for the site in question on desktop, but that is just confirming that unaffected slideshows aren't changed in anyway. Also added @sgomes as I'm modifying the aspect ratio line you'd modified last year here, though in testing with the instructions here ( #43880 ) for a regular slideshow I see no issues introduced. |
sgomes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @coder-karen, sorry for the late reply!
Sorry for introducing the issue, I imagine it was a division by zero for images where, for whatever reason, the natural size properties don't get filled in?
These changes look good to me, as they align well with what I was trying to do with my previous work 👍 Thank you!
Fixes JETPACK-1217
Proposed changes:
naturalWidthandnaturalHeightproperties, creating a fallback otherwise.heightis not added to the inline style for the images parentulelement, this filling the whole width of the parent. This can cause a visual mismatch on a page with several slideshows.Other information:
Jetpack product discussion
JETPACK-1217
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Ideally this would be tested on mobile by sandboxing the site mentioned in the above linked Linear issue (unless you can reproduce on another non Simple site), and using the generated commands in the comment below to apply the changes when sandboxed. May need mobile assistance for this.
If you can replicate the issue on mobile on a self-hosted or WoA site:
ulfor the slideshow images has no inline style height, then that should confirm the issue. Manually adding a height comparable to the other slideshows would fix it.To ensure this causes no issues for slideshows not on mobile: