Image Prioritizer

外掛說明

This plugin optimizes the loading of images (and videos) with prioritization to improve Largest Contentful Paint (LCP), lazy loading, and more accurate image size selection.

The current optimizations include:

  1. Add breakpoint-specific fetchpriority=high preload links (LINK[rel=preload]) for image URLs of LCP elements:
    1. An IMG element, including the srcset/sizes attributes supplied as imagesrcset/imagesizes on the LINK.
    2. The first SOURCE element with a type attribute in a PICTURE element. (Art-directed PICTURE elements using media queries are not supported.)
    3. An element with a CSS background-image inline style attribute.
    4. An element with a CSS background-image applied with a stylesheet (when the image is from an allowed origin).
    5. A VIDEO element’s poster image.
  2. Ensure fetchpriority=high is only added to an IMG when it is the LCP element across all responsive breakpoints.
  3. Add fetchpriority=low to IMG tags which appear in the initial viewport but are not visible, such as when they are subsequent carousel slides.
  4. Lazy loading:
    1. Apply lazy loading to IMG tags based on whether they appear in any breakpoint’s initial viewport.
    2. Implement lazy loading of CSS background images added via inline style attributes.
    3. Lazy-load VIDEO tags by setting the appropriate attributes based on whether they appear in the initial viewport. If a VIDEO is the LCP element, it gets preload=auto; if it is in an initial viewport, the preload=metadata default is left; if it is not in an initial viewport, it gets preload=none. Lazy-loaded videos also get initial preload, autoplay, and poster attributes restored when the VIDEO is going to enter the viewport.
  5. Ensure that sizes=auto is added to all lazy-loaded IMG elements.
  6. Reduce the size of the poster image of a VIDEO from full size to the size appropriate for the maximum width of the video (on desktop).

This plugin requires the Optimization Detective plugin as a dependency. Please refer to that plugin for additional background on how this plugin works as well as additional developer options.

👉 Note: This plugin optimizes pages for actual visitors, and it depends on visitors to optimize pages. As such, you won’t see optimizations applied immediately after activating the plugin. Please wait for URL Metrics to be gathered for both mobile and desktop visits. And since administrator users are not normal visitors typically, optimizations are not applied for admins by default.

There are currently no settings and no user interface for this plugin since it is designed to work without any configuration.

安裝方式

自動安裝

  1. 前往 [外掛]→[安裝外掛]
  2. Search for Image Prioritizer.
  3. Install and activate the Image Prioritizer plugin.

手動安裝

  1. Upload the entire image-prioritizer folder to the /wp-content/plugins/ directory.
  2. 前往 [外掛] 頁面。
  3. Activate the Image Prioritizer plugin.

常見問題集

使用者可以在何處提交外掛意見反應?

Feedback is encouraged and much appreciated, especially since this plugin may contain future WordPress core features. If you have suggestions or requests for new features, you can submit them as an issue in the WordPress Performance Team’s GitHub repository. If you need help with troubleshooting or have a question about the plugin, please create a new topic on our support forum.

在何處可以回報安全性程式碼錯誤?

效能團隊及 WordPress 社群對安全性程式碼錯誤一向嚴陣以待,我們非常感謝使用者披露相關發現所付出的心力,並會盡全力解決使用者提出的問題。

如需回報安全性問題,請參考 WordPress HackerOne 計畫。

如何為這個外掛做出貢獻?

非常感謝各位的各種貢獻!請參考核心程式效能團隊手冊以進一步了解參與的方式。

The plugin source code is located in the WordPress/performance repo on GitHub.

使用者評論

這個外掛目前沒有任何使用者評論。

參與者及開發者

以下人員參與了開源軟體〈Image Prioritizer〉的開發相關工作。

參與者

〈Image Prioritizer〉外掛目前已有 5 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將〈Image Prioritizer〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

0.3.0

Enhancements

  • Add preload links LCP picture elements. (1707)
  • Harden validation of user-submitted LCP background image URL. (1713)
  • Lazy load background images added via inline style attributes. (1708)
  • Preload image URLs for LCP elements with external background images. (1697)
  • Serve unminified scripts when SCRIPT_DEBUG is enabled. (1643)

0.2.0

Enhancements

  • Lazy load videos and video posters. (1596)
  • Prioritize loading poster image of video LCP elements. (1498)
  • Choose smaller video poster image size based on actual dimensions. (1595)
  • Add fetchpriority=low to occluded initial-viewport images (e.g. images in hidden carousel slides). (1482)
  • Avoid lazy-loading images and embeds unless there are URL Metrics for both mobile and desktop. (1604)

0.1.4

Enhancements

  • Move Auto Sizes logic from Enhanced Responsive Images to Image Prioritizer. (1476)

0.1.3

Bug Fixes

  • Fix handling of image prioritization when only some viewport groups are populated. (1404)

0.1.2

  • Update PHP logic to account for changes in Optimization Detective API. (1302)

0.1.1

  • Fix background-image styled tag visitor’s handling of parsing style without background-image. (1288)

0.1.0

  • Initial release.