Skip to main content

wp media image-size

Overview

List every registered image size in WordPress — from the built-in defaults (thumbnail, medium, large) to sizes added by themes, plugins, and WooCommerce. Helps you understand what derivative sizes exist before running wp media regenerate.

What It Does

wp media image-size queries the global $_wp_additional_image_sizes registry (populated by add_image_size()) and merges it with the core sizes stored in options. It returns each size's name, width, height, and crop setting.

Syntax

wp media image-size [OPTIONS]

Options

FlagDescription
--fields=FIELDSFields to display: name, width, height, crop
--format=FORMATtable, json, csv, yaml

Basic Usage

wp media image-size

Output:

+---------------------------------+-------+--------+------+
| name | width | height | crop |
+---------------------------------+-------+--------+------+
| thumbnail | 150 | 150 | hard |
| medium | 300 | 300 | soft |
| medium_large | 768 | 0 | soft |
| large | 1024 | 1024 | soft |
| full | | | |
| feature-card | 800 | 450 | hard |
| woocommerce_thumbnail | 300 | 300 | hard |
| woocommerce_single | 600 | 600 | soft |
| woocommerce_gallery_thumbnail | 100 | 100 | hard |
+---------------------------------+-------+--------+------+

Export to JSON

wp media image-size --format=json

Output:

[
{"name":"thumbnail","width":"150","height":"150","crop":"hard"},
{"name":"medium","width":"300","height":"300","crop":"soft"},
{"name":"feature-card","width":"800","height":"450","crop":"hard"},
...
]

Real-World Scenarios

Scenario 1: Verify newly registered size exists

After adding add_image_size('hero', 1280, 720, true) to your theme:

wp media image-size | grep hero

Output:

| hero                            | 1280  | 720    | hard |

Scenario 2: Export all sizes to CSV for documentation

wp media image-size --format=csv > image-sizes-$(date +%Y%m%d).csv

Scenario 3: List only core sizes

wp media image-size --format=json | jq '.[] | select(.name | test("thumbnail|medium|large"))'

Output:

{"name":"thumbnail","width":"150","height":"150","crop":"hard"}
{"name":"medium","width":"300","height":"300","crop":"soft"}
{"name":"medium_large","width":"768","height":"0","crop":"soft"}
{"name":"large","width":"1024","height":"1024","crop":"soft"}

Scenario 4: Use sizes list to selectively regenerate

# Regenerate only custom (non-core) sizes
for size in $(wp media image-size --format=json | jq -r '.[] | select(.name | test("^(thumbnail|medium|medium_large|large|full)$") | not) | .name'); do
echo "Regenerating: $size"
wp media regenerate --image-size="$size" --yes
done

Crop Values Explained

Crop ValueMeaning
hardImage is cropped to exactly the defined dimensions
softImage is scaled proportionally; dimensions are maximums
(empty)Same as soft — proportional scaling

Quick Reference

wp media image-size                        # Table view
wp media image-size --format=json # JSON
wp media image-size --format=csv # CSV export

Next Steps