2.1.0-beta2
版本发布时间: 2021-04-15 14:39:22
ampproject/amp-wp最新发布版本:2.5.4(2024-07-16 02:45:13)
This is the second beta prerelease for v2.1, after the first beta a few weeks ago. For the full list of changes coming in this release, please see the 2.1 milestone.
On top of the changes in the first beta, this prerelease includes 8 closed issues and 12 merged pull requests (excluding dependency updates). Please report any issues you encounter while testing! The 2.1 stable release is due out this month (April).
The key changes since the first beta include:
-
Improve hero image determination. The first beta included a
DetermineHeroImages
transformer which automatically identified the custom logo, header image, featured image, and content-initial cover/image blocks. However, it was only enabled by default for core themes since there were known cases where it failed to properly identify hero images, erroneously causing some images outside of the initial viewport to be prerendered. These issues have been fixed and the transformer is now enabled by default. A newHeroCandidateFiltering
service uses filters to inject thedata-hero-candidate
attribute into the custom logo and custom header images as well as in the attachment image which is the featured image for the first post in the main query. If these filters missed identifying a hero image candidate, then theDetermineHeroImages
transformer will mark all non-lazy loaded images which occur before themain
element (or the first.entry-content
) as hero image candidates. Additionally, when the originalimg
hadloading=lazy
this is now preserved on the prerendered image which mitigates the risk of accidentally marking an image out of the first viewport as a hero image. Lastly, beyond just considering the content-initial Cover block and Image block, now any image appearing as a descendant of the first content element will be considered as a hero. Note that currently only two images get identified as heroes for prerendering (but see https://github.com/ampproject/amp-toolbox-php/issues/55#issuecomment-818090508). If you want to have total control over which images are designated as heroes, you can add thedata-hero
attribute yourself. (https://github.com/ampproject/amp-wp/pull/6062, https://github.com/ampproject/amp-wp/issues/6061, https://github.com/ampproject/amp-toolbox-php/pull/141, https://github.com/ampproject/amp-toolbox-php/pull/149, https://github.com/ampproject/amp-toolbox-php/pull/144, https://github.com/ampproject/amp-toolbox-php/pull/141, https://github.com/ampproject/amp-toolbox-php/pull/136, https://github.com/ampproject/amp-toolbox-php/pull/135, https://github.com/ampproject/amp-toolbox-php/pull/115) -
Serve AMP scripts as ES modules to modern browsers. The
RewriteAmpUrls
optimizer transformer was ported to amp-toolbox-php. This transformer rewrites AMPscript
tags to usetype=module
for supporting browsers. These scripts are comprised of ES modules which reduce the overall amount of code since polyfills for older browsers are omitted. Support for older browsers remains by serving the original AMP scripts withnomodule
. This transformer also allows opting-in to the LTS versions of AMP scripts (cf. https://github.com/ampproject/amp-wp/issues/4600). Additional changes will facilitate script self-hosting in a future release. (https://github.com/ampproject/amp-wp/pull/6037, https://github.com/ampproject/amp-toolbox-php/pull/140, https://github.com/ampproject/amp-toolbox-php/pull/130, https://github.com/ampproject/amp-toolbox-php/pull/122) - Introduce AMP status panel to document sidebar and pre-publish checks. To improve visibility of AMP validation issues in the block editor when developer tools are enabled, the “Enable AMP” toggle has been moved to a new AMP panel in the document sidebar. This panel now includes the validation status message and a button to take you to the AMP Validation sidebar. This same panel is also now presented in the pre-publish checks. (https://github.com/ampproject/amp-wp/issues/5997, https://github.com/ampproject/amp-wp/pull/6027, https://github.com/ampproject/amp-wp/pull/6022)
-
Add
wp amp optimizer
WP-CLI command. (Experimental) The AMP Optimizer from amp-toolbox-php is bundled with the AMP plugin and its CLI interface is now accessible via WP-CLI. New commands includewp amp optimizer optimize
,wp amp optimizer transformer list
, andwp amp optimizer transformer config
. See pull request for details. (https://github.com/ampproject/amp-wp/issues/6053, https://github.com/ampproject/amp-wp/pull/6063, https://github.com/ampproject/amp-wp/issues/6064, https://github.com/ampproject/amp-wp/pull/6065, https://github.com/ampproject/amp-toolbox-php/pull/150, https://github.com/ampproject/amp-toolbox-php/pull/92, https://github.com/ampproject/amp-toolbox-php/pull/139) -
Inherit
object-fit
andobject-position
styles. In the past when your theme usedobject-fit
/object-position
style properties on images and videos they would not show up on AMP pages when theimg
andvideo
elements were converted intoamp-img
andamp-video
respectively. This required having to add additional AMP-specific styling. This is no longer the case as theimg
andvideo
elements that AMP creates inside ofamp-img
andamp-video
now have default styling toinherit
these style properties. This also applies to thenoscript
fallback images/videos. Special support for core themes and the Cover block were able to be removed, and cases in other themes/plugins should now more often work out of the box. The overall CSS is also reduced. (https://github.com/ampproject/amp-wp/pull/5955, https://github.com/ampproject/amp-wp/issues/6028)
The amp-toolbox-php package was updated to include changes from the 0.3.0 and 0.4.0 releases. Again, for all changes see issues and PRs closed since 2.1-beta1.
Installation
You can also install the amp.zip
build linked below by uploading it in the WordPress admin.
For up-to-the-minute builds, see the Development Builds Wiki page.
1、 amp.zip 1.71MB