@@ -13,7 +13,7 @@ This package implements the following commands:
1313
1414### wp media
1515
16- Imports files as attachments, regenerates thumbnails, or lists registered image sizes.
16+ Imports files as attachments, regenerates thumbnails, replaces existing attachment files, or lists registered image sizes.
1717
1818~~~
1919wp media
@@ -336,6 +336,46 @@ wp media regenerate [<attachment-id>...] [--image_size=<image_size>...] [--skip-
336336
337337
338338
339+ ### wp media replace
340+
341+ Replaces the file for an existing attachment while preserving its identity.
342+
343+ ~~~
344+ wp media replace <attachment-id> <file> [--skip-delete] [--porcelain]
345+ ~~~
346+
347+ ** OPTIONS**
348+
349+ <attachment-id>
350+ ID of the attachment whose file is to be replaced.
351+
352+ <file>
353+ Path to the replacement file. Supports local paths and URLs.
354+
355+ [--skip-delete]
356+ Skip deletion of old thumbnail files after replacement.
357+
358+ [--porcelain]
359+ Output just the attachment ID after replacement.
360+
361+ ** EXAMPLES**
362+
363+ # Replace an attachment file with a local file.
364+ $ wp media replace 123 ~/new-image.jpg
365+ Replaced file for attachment ID 123 with '/home/user/new-image.jpg'.
366+ Success: Replaced 1 of 1 images.
367+
368+ # Replace an attachment file with a file from a URL.
369+ $ wp media replace 123 'http://example.com/image.jpg'
370+ Replaced file for attachment ID 123 with 'http://example.com/image.jpg'.
371+ Success: Replaced 1 of 1 images.
372+
373+ # Replace and output just the attachment ID.
374+ $ wp media replace 123 ~/new-image.jpg --porcelain
375+ 123
376+
377+
378+
339379### wp media image-size
340380
341381Lists image sizes registered with WordPress.
0 commit comments