| 开发者 |
presswell
benplum |
|---|---|
| 更新时间 | 2026年10月15日 23:59 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
/pwad-image/?id=...&size=...). The plugin includes an automatic compatibility check in wp-admin.
Regenerator
The Regenerator screen (Media -> Regenerate Thumbnails) builds a queue and processes images in batches, with progress metrics and retry handling for failed jobs. You can choose exactly which sizes should be regenerated.
Documentation
Public APIs
pwad_add_image_size( $args )
name, key, height, width, crop (optional), and optionally thumbnails values.[size]-[thumbnail].thumbnail, large, my-size, my-size-mobile, etc.)thumbnail, large, my-size, my-size-mobile, etc.)file, url, path, height, width, and mime-type values.
Example:
$square_large = pwad_get_image_src( $img_ID, 'square' );
$square_small = pwad_get_image_src( $img_ID, 'square-small' );
Actions
pwad/image_generated
Fires immediately after a custom crop file is generated so themes/plugins can queue optimizers or post-processing.
Arguments:
label (string), value (string), and status (ok, warning, or empty). Rows without a string label and value are skipped.--queue-per-page=<int> (default 200)--batch-size=<int> (default 25)--target-seconds=<float> (default 5)--resume-last=<0|1> (default 0, continue the last interrupted queue)--sitemap=<url> (optional, auto-detects from robots.txt/common sitemap endpoints)--page-limit=<int> (default unlimited)--image-limit=<int> (default unlimited)--delay-ms=<int> (default 250)--timeout=<float> (default 10)--retries=<int> (default 2)--include-external=<0|1> (default 0)--force-endpoint=<0|1> (default 0)--report-csv=<path> (optional, writes per-URL status/error report; relative paths are saved privately in wp-content/uploads/pwad-logs/)--dry-run=<0|1> (default 0)--resume-last=<0|1> (default 0, continue the last interrupted prime run)--sitemap=<url> (optional, auto-detects from robots.txt/common sitemap endpoints)--batch-size=<int> (default 200)--max-images=<int> (default unlimited)--page-limit=<int> (default unlimited)--image-limit=<int> (default unlimited)--timeout=<float> (default 10)--grace-days=<int> (default 0, uses file modified time)--include-external=<0|1> (default 0)--force-endpoint=<0|1> (default 0)--report-csv=<path> (optional, writes per-file keep/delete report; relative paths are saved privately in wp-content/uploads/pwad-logs/)--dry-run=<0|1> (default 1)--resume-last=<0|1> (default 0, continue the last interrupted prune run)--batch-size=<int> (default 200)--max-images=<int> (default unlimited)--include-default=<0|1> (default 0)--dry-run=<0|1> (default 1)--resume-last=<0|1> (default 0, continue the last interrupted clean run)wp-content/plugins/.
Configuration
When viewing an image in the media library click the 'Set Focal Point' button. Use the size dropdown to change the crop preview. Click and drag the blue focal point marker to identify the subject of the image. When finished, click the 'Save Focal Point' button to update the focal point settings and clear the image thumbnail cache for regeneration.
Focal points let you control crop framing across many sizes without manually defining crop coordinates for every variant.
Themes often register many custom sizes, but only a subset are used on the live site. Dynamic generation creates only the thumbnails that are actually requested.
Endpoint Mode serves generated images through a WordPress endpoint when your server does not pass filename-based 404 image requests to WordPress. The plugin can auto-enable this mode when compatibility checks fail.
Open Media -> Regenerate Thumbnails and run the regenerator, or run wp pwad regenerate from WP-CLI.
When migrating a large site it is beneficial to delete any generated image sizes to speed up the data transfer. Images will be re-generated dynamically when requested from the new location.
Turn on Image Block Support under Settings -> Art Direction. The Image block's Resolution then lists your image sets (with core's Thumbnail, Medium, Large, and Full Size) instead of every generated size, and srcset serves each set's smaller sizes. Pick a set to choose the image's shape: it uses the set's real crop, cut around the image's focal point. The block's Art Direction panel shows which set is in use and lets you drag the image's focal point without leaving the editor, with any set's crop outlined on the image (it starts with the block's Resolution). Saving rebuilds the image's crops around the new point; the focal point belongs to the image, so it applies everywhere the image is used. The Image block's aspect ratio presets are removed, so shapes come from your sets rather than CSS crops; other blocks keep the theme's presets. Image blocks that already use an aspect ratio matching a set are served that set's crop, and other aspect ratios are centred on the image's focal point. Nothing is changed in saved posts, so turning the setting off returns everything to how it was.
Add the Art Directed Image block. Choose an image, then pick an image set for Desktop, Tablet, and Mobile in the block's sidebar; tablet uses the desktop crop and mobile uses the tablet crop unless you choose another. Choosing a device also switches the editor's preview, so the canvas shows the crop you're working on. The block outputs a <picture> element, so browsers download only the crop that fits the screen.
The breakpoints come from WordPress itself (480px for mobile and 782px for tablet by default, or your theme's settings.viewport in theme.json), so crops switch exactly where the editor's device preview and the theme's responsive styles do. The block has the same focal point editor as the Image block, plus alt text, a caption, alignment, and a transform to and from the Image block.
Settings -> Art Direction -> Debug has a status table covering how images are generated and served (Smart Cache, Compatibility Mode, missing file requests, the image editor, the uploads folder, and custom sizes), focal points, the last regenerator and cache command runs, and any conflicting plugins. It also has an image debugger that shows every size and URL for one image, and the private debug log.
pwad/image_generated action for post-processing.