index.md
41 lines
| 1 | # CLI |
| 2 | |
| 3 | TinyPNG provides several CLI commands allowing you to automate actions on your website. |
| 4 | |
| 5 | ## Commands |
| 6 | |
| 7 | ### `wp tiny optimize` |
| 8 | |
| 9 | Optimizes images in the WordPress media library. |
| 10 | When run without arguments, all images that have not yet been optimized are processed. You can also target specific attachments by providing a comma-separated list of attachment IDs. |
| 11 | |
| 12 | **Options** |
| 13 | |
| 14 | | Option | Description | |
| 15 | |---|---| |
| 16 | | `--attachments=<ids>` | Comma-separated list of attachment IDs to optimize. Omit to optimize all unoptimized images. | |
| 17 | |
| 18 | **Examples** |
| 19 | |
| 20 | Optimize all unoptimized images: |
| 21 | |
| 22 | ```bash |
| 23 | wp tiny optimize |
| 24 | ``` |
| 25 | |
| 26 | Optimize specific attachments by ID: |
| 27 | |
| 28 | ```bash |
| 29 | wp tiny optimize --attachments=532,603,705 |
| 30 | ``` |
| 31 | |
| 32 | **Output** |
| 33 | |
| 34 | Skipped attachments (invalid or unsupported file types) are reported as warnings. When finished, a summary shows how many images were successfully optimized. |
| 35 | |
| 36 | ``` |
| 37 | Optimizing 3 images. |
| 38 | Optimizing images: 100% (3 of 3) |
| 39 | Success: Done! Optimized 3 of 3 images. |
| 40 | ``` |
| 41 |