
內容簡介
在現代網頁設計中,設計師會在網頁上創建不同尺寸的圖像以營造吸引人的版面配置。 如果網頁是使用 WordPress 構建的,開發人員需要在主題中註冊每個圖像尺寸,以確保如果客戶上傳不同尺寸的圖像,不會破壞版面配置。
通過新的 WordPress 安裝,默認情況下會創建三個尺寸,例如縮略圖(150 x 150)、中等(300 x 300)、大型(1024 x 1024),這意味著每當上傳新圖像時,WordPress 將在服務器上保留至少四個圖像副本,一個原始圖像和 3 個根據圖像大小進行裁剪的圖像副本。
當開發人員/設計師需要不同尺寸的圖像時,他們會註冊更多的圖像尺寸,例如英雄、產品縮略圖、產品大圖、團隊成員圖像等,具體取決於頁面的設計。
現在假設我們在主題中定義了 3 個默認和 3 個自定義圖像尺寸,現在每當上傳新圖像,WordPress 將創建 6 個圖像副本和 1 個原始圖像,即使我們只需要在網站上的特定區域使用其中 1 個,其餘副本仍然存在於服務器上並且會佔用空間。 想象一下當我們有許多帖子和頁面擁有不同的圖像時,WordPress 創建了多少無用的圖像,這些圖像只會佔用服務器空間。 在 Woo-Commerce 網站的情況下,如果您需要為主頁上的新滑動圖像或關於頁面的英雄圖像上傳圖像,它將創建許多副本,包括 Woo-commerce 自己註冊的不同尺寸的產品圖像尺寸。
最終,網站速度和服務器空間會受到影響。
為了解決這個問題,我們開發了一個 WP Image Sizes 插件,此插件允許用戶決定每次通過 WordPress 上傳圖像時應該創建哪些圖像尺寸。
安裝 WP Image Sizes 後,它將創建一個設置頁面,用戶可以在其中為每個 CPT 指定圖像尺寸,例如,用戶可以為英雄/滑块 CPT 指定一個尺寸,為團隊成員和推薦信指定另一個尺寸。在為每個 CPT 指定圖像尺寸後,當用戶上傳新圖像時,WP Image Sizes 將只允許 WordPress 創建被指定給 CPT 的圖像尺寸的副本。
如果用戶嘗試從媒體上傳圖像,它將在媒體上傳器中顯示選項,以選擇用戶需要的圖像尺寸,WP Image Sizes 將只創建該圖像尺寸。
WP Image Sizes 插件可以節省大量服務器空間,並協助使 WordPress 網站更加快速。
PRO
WP Image Sizes 插件還有一個專業版,其中包括更多功能,請參閱此處
外掛標籤
開發者團隊
原文外掛簡介
Every time you upload an image, WordPress doesn’t just store your file — it generates a separate cropped copy for every registered image size. A fresh install already creates three (thumbnail, medium, and large) on top of the original, so a single upload becomes four files on your server.
Themes and plugins add many more. A typical site might register hero, slider, product thumbnail, team member, and testimonial sizes — and WooCommerce adds several of its own. With six registered sizes, one upload turns into seven files, even when the page only ever displays one of them. The rest sit on disk doing nothing but consuming space.
Multiply that across hundreds of posts, pages, and products and the waste adds up fast: bloated storage, slower backups, and longer upload processing. It’s especially painful on WooCommerce sites, where uploading a single banner or hero image also generates the full set of product thumbnail sizes you’ll never use for that image.
WP Image Sizes fixes this by letting you decide which sizes WordPress is allowed to create.
Per post type control — Assign the exact image sizes that matter to each post type from a simple settings page. A slider post type might only need one large size; testimonials might only need a thumbnail.
Choose sizes at upload time — When you add media, the uploader shows the available sizes so you can pick what gets generated for that specific upload.
Disable thumbnails entirely — Skip generating any additional sizes for a post type or a single upload when you only need the original.
No lock-in — WP Image Sizes never caches or alters your files. Any images already generated stay intact, even if you deactivate or remove the plugin.
The result is a leaner media library, less wasted disk space, and a faster, lighter WordPress site.
PRO
The free plugin controls which sizes get generated on new uploads. WP Image Sizes Pro extends this to your existing media and adds automation:
Bulk Create Image Sizes — Generate selected image sizes for all existing images of a chosen post type. Perfect after registering a new size or switching themes.
Bulk Delete Image Sizes — Remove unwanted image size files from existing media to reclaim server space in one click.
Create Images on Runtime — Automatically generate a missing image size the moment it is first requested on the front end, instead of pre-creating every size.
Get WP Image Sizes Pro
