前言介紹
- 這款 WordPress 外掛「Media Placeholders」是 2013-08-11 上架。
- 目前有 80 個安裝啟用數。
- 上一次更新是 2015-02-25,距離現在已有 3721 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.5 以上版本才可以安裝。
- 有 2 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
xwp | westonruter |
外掛標籤
404 | images | uploads | development | placeholders |
內容簡介
啟用此外掛可將您的網誌上所有找不到的上傳圖片導向您最喜愛的替代圖片服務,例如 placehold.it 或 placekitten.com。請注意,雖然小貓很可愛,但 placehold.it 服務更實用,因為所有圖片尺寸的背景和前景色彩都相同(例如在圖片輸出格式為全尺寸或縮圖的圖庫中)能輕鬆區別每張圖片。您可以通過定義 MISSING_UPLOADED_IMAGE_PLACEHOLDER_BUILTIN 為 placekitten_color 或 placekitten_grayscale,或者透過 missing_uploaded_image_placeholder_builtin 做為篩選器來將默認的 placehold.it 服務更換成 placekitten.com。
此外掛僅建議開發期使用。您應該在本地開發環境(例如 Vagrant 或 XAMPP)或編寫的清單伺服器上啟用此外掛。這個外掛在團隊合作時非常有用,團隊共享資料庫備份但不包括上傳圖片(這些圖片必須從程式庫中省略),因此當您將資料庫備份交給其他工程師時,如果啟用此外掛,他們將看到上傳圖片的替代圖片。此外掛提供了一個類似於 Uploads by Proxy 外掛的替代方案。
若您在另一台沒有上傳文件的環境上應用了生產資料庫備份,但您知道所有在資料庫中引用的圖片都存在於生產環境,您可以定義 MISSING_UPLOADED_IMAGE_REDIRECT_SERVER 常數,或透過篩選器 missing_uploaded_image_redirect_server 來使替代圖片服務失效,並將圖片請求重新導向至生產伺服器。
如果您使用舊的上傳文件系統,在多站網路中不適用,且 URL 中包含 /files/,在核心 #19235 中,可以看到解決方法。設定失敗的原因也可能是缺少在 Apache/Nginx 上啟用 WordPress 404 錯誤處理。如果您使用 Nginx 和 Varying Vagrant Vagrants 的預設配置,則需從 nginx-wp-common.conf 中刪除 png|jpg|jpeg|gif,以避免發生錯誤,該位置規則可處理所有靜態資源並直接提供文件的服務。
您可以通過篩選器 missing_uploaded_image_placeholder,添加支援您喜愛的替代圖片服務。
例如您可以在 functions.php 中添加以下代碼,或將其投入 mu-plugin 中:
<?php
/**
* 使用 Flickholdr 來作為替代場景服務
* @param null|string $url
* @param array $args 包含附加文件,寬度、高度和附件 ID
*/
function my_filter_missing_uploaded_image_placeholder( $url, $args ) {
$attachment = get_post( $args['attachment_id'] );
$tags = join( ' ', array(
$attachment->post_title,
$attachment->post_excerpt,
$attachment->post_content,
$attachment->_wp_attachment_image_alt
) );
$tags = strtolower( preg_replace( '#[^A-Za-z0-9]+#', ',', $tags ) );
$tags =
原文外掛簡介
Activate this plugin to redirect all requests for missing uploaded images on your blog to your favorite placeholder image service, such as placehold.it or placekitten.com. Note that although kittens are cute, the placehold.it service is actually more useful because the background and foreground color can remain consistant across all image sizes (e.g. full size vs thumbnail in a gallery), and so it is easier to see which images in a page are related to each other. (You can change the default placehold.it service to placekitten.com by defining MISSING_UPLOADED_IMAGE_PLACEHOLDER_BUILTIN to be placekitten_color or placekitten_grayscale, or supplying those same values via the missing_uploaded_image_placeholder_builtin filter).
This plugin is for use during development only. It is expected that this plugin will be activated on your local development environment (e.g. on Vagrant or XAMPP), or on your staging server. This plugin is especially useful when working on a team where you share around a database dump but not the uploaded images (which should always be omitted from the code repository), so if you give a database dump to another developer but don’t include the uploaded images, with this plugin enabled they will see a placeholder where the uploaded image appears. This plugin is an alternative approach to what is offered by the Uploads by Proxy plugin.
If you have applied the production database to another environment which lacks the uploaded files, but you know that all images referenced in the database do exist on production, you can define the MISSING_UPLOADED_IMAGE_REDIRECT_SERVER constant or filter missing_uploaded_image_redirect_server to short-circuit the placeholder service and redirect the image request to that server.
This plugin will not work if you are on a multisite network that uses the old system for referring to uploaded files, where the URL includes /files/ which is intercepted by a rewrite rule and passed directly to ms-files.php. See #19235. Similarly, make sure that missing uploaded files get served by the WordPress 404 handler, not Apache/Nginx. If you are using Nginx with the default Varying Vagrant Vagrants config, you’ll want to remove png|jpg|jpeg|gif from the following location rule in nginx-wp-common.conf (or remove it altogether):
# Handle all static assets by serving the file directly. Add directives
# to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
You can add support for your own favorite placeholder services by filtering missing_uploaded_image_placeholder.
For example, you can add this to your functions.php or drop it into a mu-plugin:
post_title,
$attachment->post_excerpt,
$attachment->post_content,
$attachment->_wp_attachment_image_alt
) );
$tags = strtolower( preg_replace( '#[^A-Za-z0-9]+#', ',', $tags ) );
$tags = trim( $tags, ',' );
$url = sprintf( 'http://flickholdr.com/%d/%d/%s', $args['width'], $args['height'], $tags );
return $url;
}
add_filter( 'missing_uploaded_image_placeholder', 'my_filter_missing_uploaded_image_placeholder', 10, 2 );
Development of this plugin is done on GitHub. Pull requests welcome. Please see issues reported there before going to the plugin forum.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Media Placeholders」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Autoptimize 》Autoptimize 能夠輕鬆優化您的網站。它可以整合、縮小和快取腳本和樣式表,在默認情況下向頁面 head 中注入 CSS,但也可以內嵌關鍵 CSS 並延遲整合的完整 CSS...。
WebP Express 》ch means less bandwidth usage and faster page load times., Easy to use - with little effort, WordPress site admins can have their site serving auto...。
Recent Posts Widget With Thumbnails 》列出最新的文章標題、縮略圖、摘要、作者、類別、日期等等!, 雖然此外掛僅建立在小工具區域,但使用者報告說它在 Elementor 和 Oxygen 上運作順暢。但它是否...。
Modern Image Formats 》外掛介紹:此外掛可在 WordPress 應用程式中增加 WebP 支援,但僅針對新上傳的影像檔案轉換成 WebP 格式,現有檔案不會轉換。預設情況下,WebP 只會針對 JPEG...。
Responsive Lightbox & Gallery 》提供完整的 WordPress 相簿外掛所需一切, Responsive Lightbox and Gallery 外掛是一個全功能的 WordPress 相簿外掛,擁有強大的拖放相簿生成器和 Lightbox ...。
Lightbox & Modal Popup WordPress Plugin – FooBox 》FooBox是第一個嚴肅考慮響應式佈局的燈箱。它不僅會將圖片縮放以在手機上呈現更好的效果,還會重新排列按鈕控制,使其在縱向或橫向的方向上都展現出色的外觀...。
Media Cleaner: Clean your WordPress! 》Media Cleaner 是一個強大的外掛,它可以幫助你清理 WordPress 媒體庫中未使用的媒體條目和文件,以及修復損壞的條目。內置回收站功能讓你可以在永久刪除之前...。
Media Library Assistant 》媒體庫助手提供多個增強功能,方便管理媒體庫,其中包括:, , , , [mla_gallery] 短碼,在文章、頁面或自訂文章類型中使用,添加圖片和/或其他媒體庫項目(...。
Image Placeholders 》總結:, 這個外掛可以在WordPress的媒體庫中確定並儲存新上傳圖片的主要顏色,並且利用它在前端建立一個相應顏色的佔位背景,在圖片加載之前可見。, , 問題與...。
Image Watermark 》Image Watermark 外掛能讓您自動給 WordPress 媒體庫上傳的圖片打上浮水印,也可大量添加浮水印到之前上傳的圖片之中。, 欲進一步瞭解,請前往dFactory的外掛...。
FancyBox for WordPress 》本外掛能讓FancyBox輕鬆整合到您的部落格:上傳,啟用,完成。您也能選擇進行更多的設置。, 您幾乎可以對Fancybox lightbox的所有屬性進行自定義:邊框、邊緣...。
Crop-Thumbnails 》此外掛提供調整裁切圖像的裁切區域功能。它會在編輯頁面和媒體對話框中添加按鈕,以便進入裁剪編輯器。, 在裁剪編輯器中,您可以選擇一個或多個(如果它們具...。
Clean Image Filenames 》這個外掛可以在您上傳至媒體庫時自動將檔名中的語言重音符號轉換。轉換後的字符將會變成網頁和伺服器友好、無語言重音的字元。, 功能, , 將瑞典語、丹麥語、...。
Enhanced Responsive Images 》這個外掛程式實現了將 sizes="auto" 加入到懶加載圖片的 HTML 規格。, 相關背景資訊請參考:https://github.com/whatwg/html/issues/4654。, , 問...。
Optimus – WordPress Image Optimizer 》WordPress圖片優化器, Optimus可自動降低已上傳媒體檔案的檔案大小。根據圖片和格式,可以減少高達70%的大小。每張圖片可以節省數千位元組,這些節省可以對博...。