Mô tả
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:
- Add breakpoint-specific
fetchpriority=high
preload links (both asLINK[rel=preload]
elements andLink
response headers) for image URLs of LCP elements:- An
IMG
element, including thesrcset
/sizes
attributes supplied asimagesrcset
/imagesizes
on theLINK
. - The first
SOURCE
element with atype
attribute in aPICTURE
element. (Art-directedPICTURE
elements using media queries are not supported.) - An element with a CSS
background-image
inlinestyle
attribute. - An element with a CSS
background-image
applied with a stylesheet (when the image is from an allowed origin). - A
VIDEO
element’sposter
image.
- An
- Ensure
fetchpriority=high
is only added to anIMG
when it is the LCP element across all responsive breakpoints. - Add
fetchpriority=low
toIMG
tags which appear in the initial viewport but are not visible, such as when they are subsequent carousel slides. - Lazy loading:
- Apply lazy loading to
IMG
tags based on whether they appear in any breakpoint’s initial viewport. - Implement lazy loading of CSS background images added via inline
style
attributes. - Lazy-load
VIDEO
tags by setting the appropriate attributes based on whether they appear in the initial viewport. If aVIDEO
is the LCP element, it getspreload=auto
; if it is in an initial viewport, thepreload=metadata
default is left; if it is not in an initial viewport, it getspreload=none
. Lazy-loaded videos also get initialpreload
,autoplay
, andposter
attributes restored when theVIDEO
is going to enter the viewport.
- Apply lazy loading to
- Responsive image sizes:
- Compute the
sizes
attribute using the widths of an image collected from URL Metrics for each breakpoint (when not lazy-loaded since then handled bysizes=auto
). - Ensure
sizes=auto
is set onIMG
tags after setting correct lazy-loading (above).
- Compute the
- Reduce the size of the
poster
image of aVIDEO
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.
Your site must have the REST API accessible to unauthenticated frontend visitors since this is how metrics are collected about how a page should be optimized. There are currently no settings and no user interface for this plugin since it is designed to work without any configuration.
Cài đặt
Cài đặt từ trong WordPress
- Hãy truy cập Plugin > Thêm mới.
- Tìm kiếm Ưu tiên Hình ảnh.
- Cài đặt và kích hoạt plugin Ưu tiên Hình ảnh.
Cài đặt thủ công
- Tải lên toàn bộ thư mục
image-prioritizer
vào thư mục/wp-content/plugins/
. - Truy cập Plugin.
- Kích hoạt plugin Ưu tiên Hình ảnh.
Hỏi đáp
-
Tôi có thể gửi phản hồi về plugin của mình ở đâu?
-
Phản hồi được khuyến khích và rất được hoan nghênh, đặc biệt là vì plugin này có thể chứa các tính năng cốt lõi của WordPress trong tương lai. Nếu bạn có đề xuất hoặc yêu cầu về tính năng mới, bạn có thể gửi chúng dưới dạng sự cố trong kho lưu trữ GitHub của Nhóm Hiệu suất WordPress. Nếu bạn cần trợ giúp về khắc phục sự cố hoặc có câu hỏi về plugin, vui lòng tạo một chủ đề mới trên diễn đàn hỗ trợ của chúng tôi.
-
Tôi có thể báo cáo lỗi bảo mật ở đâu?
-
Nhóm Hiệu suất và cộng đồng WordPress rất coi trọng các lỗi bảo mật. Chúng tôi đánh giá cao những nỗ lực của bạn trong việc tiết lộ có trách nhiệm những phát hiện của mình và sẽ nỗ lực hết sức để ghi nhận những đóng góp của bạn.
Để báo cáo sự cố bảo mật, vui lòng truy cập chương trình WordPress HackerOne.
-
Làm cách nào để tôi có thể đóng góp cho plugin?
-
Chúng tôi luôn hoan nghênh các đóng góp! Tìm hiểu thêm về cách tham gia vào Sổ tay Nhóm Hiệu suất Cốt lõi.
Mã nguồn của plugin plugin source code được đặt trong kho lưu trữ WordPress/performance trên GitHub.
Đánh giá
Không có đánh giá nào cho plugin này.
Người đóng góp & Lập trình viên
“Ưu tiên Hình ảnh” là mã nguồn mở. Những người sau đã đóng góp vào plugin này.
Những người đóng góp“Ưu tiên Hình ảnh” đã được dịch qua 5 ngôn ngữ. Cảm ơn những người tham gia dịch vì đóng góp của họ.
Dịch “Ưu tiên Hình ảnh” sang ngôn ngữ của bạn.
Muốn tham gia phát triển?
Duyệt code, check out SVN repository, hoặc theo dõi nhật ký phát triển qua RSS.
Nhật ký thay đổi
1.0.0-beta2
Enhancements
- Update
OD_HTML_Tag_Processor::next_tag()
to allow$query
arg and prepare to skip visiting tag closers by default. (1872) - Expose the logging functions to client-side extensions and automatically account for the value of
isDebug
. (1895)
Bug Fixes
- Fix URL encoding in Link HTTP response header. (1907)
- Fix unpredictable LCP element being identified in a URL Metric Group. (1903)
1.0.0-beta1
Enhancements
- Bump version to 1.0.0-beta1 to indicate graduation from being experimental. See 1846.
- Compute responsive
sizes
attribute based on thewidth
from theboundingClientRect
in captured URL Metrics. (1840)
0.3.1
Bug Fixes
- Remove erroneous check for resource initiator type when considering whether to submit LCP background image. (1760)
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
- Cập nhật logic PHP để giải thích cho các thay đổi trong API Optimization Detective. (1302)
0.1.1
- Khắc phục xử lý phân tích kiểu mà không có background-image của khách truy cập thẻ được tạo kiểu background-image. (1288)
0.1.0
- Phát hành lần đầu.