內容簡介
這是一個 WordPress 外掛程式,可以啟用 WebP 圖片上傳到媒體庫。
同時,外掛會在 body 標籤上新增一個類別,以便使用 CSS 選擇器,方便設定背景圖片。
例如:
selector {
background: url(‘images/example.jpg’);
}
body.supports-webp #selector {
background: url(‘images/example.webp’);
}
在範本檔案中使用函數 webpSupported(),以條件式顯示 WebP 圖片。
例如:
if (webpSupported()) :
這裡是 WebP 圖片
else:
這裡是其他後備格式的圖片
endif;
WP Enable WebP 的主要特色包括:
啟用 WebP 圖片上傳到媒體庫。
瀏覽器偵測,並在 body 標籤上新增一個類別,以指示瀏覽器是否支援 WebP 格式。
提供一個輔助函數,供主題範本檔案檢查瀏覽器是否支援 WebP 圖片格式。
外掛標籤
開發者團隊
原文外掛簡介
This WordPress Plugin for WebP image uploads enabled WebP image uploads into the media library.
It will also add a class to the body tag for CSS selectors. This is helpful for setting background images.
Example:
selector {
background: url(‘images/example.jpg’);
}
body.supports-webp #selector {
background: url(‘images/example.webp’);
}
Use the function webpSupported() in template files to conditionally show WebP images.
Example:
if (webpSupported()) :
WebP image here
else:
Image with other fallback format here
endif;
Major features in WP Enable WebP include:
Enabling WebP Image uploads into the media library.
Browser detection that adds a class to the body tag indicating WebP is supported by the browser.
Helper function to use in theme template files to check if the browser supports WebP image format.
