-
Notifications
You must be signed in to change notification settings - Fork 798
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
Add AMP compatibility to Slideshow shortcode #15319
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: June 2, 2020. |
Caution: This PR has changes that must be merged to WordPress.com |
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.
This works well. Reusing the work from the Slideshow block is a smart take on this. I only have one remark about this.
…ideshow block Also, add some test cases for the AMP output, and enqueue the stylesheet for the Slideshow block.
This should help to ensure regressions, to maybe prevent wp_list_pluck() from throwing an error if there's no 'id' index.
Instead of hard-coding the image URL in the expected markup, dynamically replace it.
It looks like at least one failed Travis build is from lazy-loaded images
9f449fc
to
e77a7fb
Compare
- Apply a consistent size and make width/height variable
@jeherve I've updated the tests here to use dynamic image sizes based on the The Travis Failure for e2e looks unrelated to this code. |
Since the block is set to autoplay as soon as you pass an autoplay string parameter, regardless of its value, let's not pass that parameter unless necessary.
Let's not aim to validate the full slideshow markup. Instead, focus on pieces that indicate that the parameters are respected, and that the block is used.
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.
I've made a few changes to this PR as tests were still problematic on WordPress.com.
- I cleaned up the array producing CSS classes for Gutenberg blocks, as it was previously outputting empty spaces for classes that were set as
null
- I reworked the autostart / autoplay conditions, as things work a bit differently between the block and the shortcode: the shortcode is set to autostart by default, while the block will not autoplay by default, but will autoplay as soon as you provide an autoplay parameter.
- I simplified the tests. I don't think we need to check for the entirety of the slideshow markup; what's interesting in my opinion is whether the AMP markup is being used, and if the parameters are respected.
Let me know what you think about it!
Hm, tests are failing on PHP 5.6 because of this: I'll need to work around this. |
LGTM! 👍 |
r207455-wpcom and r207427-wpcom |
Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
The attribute
type="slideshow"
is what triggers the code below.<amp-carousel>
, and it displays captions if the images have them:This won't look exactly like the non-AMP endpoint, but it should have the same images.
master
branchProposed changelog entry for your changes: