# wp media

Aide:

```bash
$ wp help media
```

```bash
NAME

  wp media

DESCRIPTION

  Imports files as attachments, regenerates thumbnails, or lists registered image sizes.

SYNOPSIS

  wp media <command>

SUBCOMMANDS

  image-size      Lists image sizes registered with WordPress.
  import          Creates attachments from local files or URLs.
  regenerate      Regenerates thumbnails for one or more attachments.
```

Afficher les tailles d'image:

```bash
$ wp media image-size
+--------------+-------+--------+------+-------+
| name         | width | height | crop | ratio |
+--------------+-------+--------+------+-------+
| full         |       |        | N/A  | N/A   |
| medium_large | 768   | 0      | soft | N/A   |
| large        | 610   | 610    | soft | N/A   |
| medium       | 400   | 400    | soft | N/A   |
| thumbnail    | 200   | 200    | hard | 1:1   |
+--------------+-------+--------+------+-------+
```

Regénérer toutes les vignettes (<u>sans confirmation</u>):

```bash
$ wp media regenerate --yes
Found 20 images to regenerate.
1/20 Regenerated thumbnails for "2016-06-24_LaPleureuse-LaSauffaz_0729" (ID 70).
2/20 Regenerated thumbnails for "2016-06-24_CascadeDeLaPleureuse_0700" (ID 69).
3/20 Regenerated thumbnails for "2016-06-24_TorrentDeSales_0844" (ID 68).
4/20 Regenerated thumbnails for "2016-06-23_CirqueDuFerACheval_0498" (ID 67).
5/20 Regenerated thumbnails for "2008-09-09_BihoreauGris_2081" (ID 35).
6/20 Regenerated thumbnails for "2008-09-08_BihoreauGris_1889" (ID 34).
7/20 Regenerated thumbnails for "2008-09-08_BihoreauGris_1858" (ID 33).
8/20 Regenerated thumbnails for "2008-09-08_BihoreauGris_1797" (ID 32).
9/20 Regenerated thumbnails for "2008-09-07_BihoreauGris_1113" (ID 31).
10/20 Regenerated thumbnails for "2008-09-07_BihoreauGris_1052" (ID 30).
11/20 Regenerated thumbnails for "2008-09-07_BihoreauGris_1030" (ID 29).
12/20 Regenerated thumbnails for "2008-09-07_BihoreauGris_1028" (ID 28).
13/20 Regenerated thumbnails for "2016-09-26_Brame_7811" (ID 25).
14/20 Regenerated thumbnails for "2016-09-26_Brame_7775" (ID 24).
15/20 Regenerated thumbnails for "2016-09-26_Brame_7801" (ID 23).
16/20 Regenerated thumbnails for "logo" (ID 15).
17/20 Regenerated thumbnails for "2014-09-13_BolClassic_7483" (ID 13).
18/20 Regenerated thumbnails for "2014-09-13_BolClassic_7126" (ID 12).
19/20 Regenerated thumbnails for "2014-09-13_BolClassic_7040" (ID 11).
20/20 Regenerated thumbnails for "2014-09-13_BolClassic_6826" (ID 10).
Success: Regenerated 20 of 20 images.
```

Regénérer toutes les vignettes de taille <u>large</u>:

```bash
$ wp media regenerate --image_size=large
Do you really want to regenerate the "large" image size for all images? [y/n] y
Found 20 images to regenerate.
1/20 Regenerated "large" thumbnail for "2016-06-24_LaPleureuse-LaSauffaz_0729" (ID 70).
2/20 Regenerated "large" thumbnail for "2016-06-24_CascadeDeLaPleureuse_0700" (ID 69).
3/20 Regenerated "large" thumbnail for "2016-06-24_TorrentDeSales_0844" (ID 68).
4/20 Regenerated "large" thumbnail for "2016-06-23_CirqueDuFerACheval_0498" (ID 67).
5/20 Regenerated "large" thumbnail for "2008-09-09_BihoreauGris_2081" (ID 35).
6/20 Regenerated "large" thumbnail for "2008-09-08_BihoreauGris_1889" (ID 34).
7/20 Regenerated "large" thumbnail for "2008-09-08_BihoreauGris_1858" (ID 33).
8/20 Regenerated "large" thumbnail for "2008-09-08_BihoreauGris_1797" (ID 32).
9/20 Regenerated "large" thumbnail for "2008-09-07_BihoreauGris_1113" (ID 31).
10/20 Regenerated "large" thumbnail for "2008-09-07_BihoreauGris_1052" (ID 30).
11/20 Regenerated "large" thumbnail for "2008-09-07_BihoreauGris_1030" (ID 29).
12/20 Regenerated "large" thumbnail for "2008-09-07_BihoreauGris_1028" (ID 28).
13/20 Regenerated "large" thumbnail for "2016-09-26_Brame_7811" (ID 25).
14/20 Regenerated "large" thumbnail for "2016-09-26_Brame_7775" (ID 24).
15/20 Regenerated "large" thumbnail for "2016-09-26_Brame_7801" (ID 23).
16/20 No "large" thumbnail regeneration needed for "logo" (ID 15).
17/20 Regenerated "large" thumbnail for "2014-09-13_BolClassic_7483" (ID 13).
18/20 Regenerated "large" thumbnail for "2014-09-13_BolClassic_7126" (ID 12).
19/20 Regenerated "large" thumbnail for "2014-09-13_BolClassic_7040" (ID 11).
20/20 Regenerated "large" thumbnail for "2014-09-13_BolClassic_6826" (ID 10).
Success: Regenerated 20 of 20 images.
```

Regénérer toutes les vignettes pour les <u>attachement d'ID</u> suivants:

```bash
$ wp media regenerate 10 11 12
Found 3 images to regenerate.
1/3 Regenerated thumbnails for "2014-09-13_BolClassic_7040" (ID 11).
2/3 Regenerated thumbnails for "2014-09-13_BolClassic_7126" (ID 12).
3/3 Regenerated thumbnails for "2014-09-13_BolClassic_6826" (ID 10).
Success: Regenerated 3 of 3 images.
```

Regénérer toutes les vignettes pour les <u>attachement d'ID 10 à 20</u>:

```bash
$ seq 10 20 | xargs wp media regenerate
Found 5 images to regenerate.
1/5 Regenerated thumbnails for "logo" (ID 15).
2/5 Regenerated thumbnails for "2014-09-13_BolClassic_7483" (ID 13).
3/5 Regenerated thumbnails for "2014-09-13_BolClassic_7040" (ID 11).
4/5 Regenerated thumbnails for "2014-09-13_BolClassic_7126" (ID 12).
5/5 Regenerated thumbnails for "2014-09-13_BolClassic_6826" (ID 10).
Success: Regenerated 5 of 5 images.
```

Importer une image locale pour être "i<u>mage à la une</u> " pour un post:

```bash
$ wp media import ~/Downloads/image.png --post_id=123 --title="A downloaded picture" --featured_image
Success: Imported file '/home/person/Downloads/image.png' as attachment ID 1753 and attached to post 123 as featured image.
```

Importer un paquet d'images:

```bash
$ wp media import images_folder/*
```