WordPress Media Library
The Media Library keeps all the files you upload: images, videos, audio, PDF and other documents. You can open it from Media > Library, and you can upload a new file from Media > Add Media File, or directly inside the post editor.
Where are the files saved?
Uploaded files are saved in the wp-content/uploads folder. By default, WordPress puts them in month and year folders (like 2026/11) and this can be changed in Settings > Media. Every file also gets an entry in the database as a post of type attachment.
Image sizes
When you upload an image, WordPress makes smaller copies of it for the themes to use. This is the list of sizes of a fresh WordPress 7.1 site:
$ wp media image-size
name width height crop ratio
full N/A N/A
2048×2048 2048 2048 soft N/A
1536×1536 1536 1536 soft N/A
large 1024 1024 soft N/A
medium_large 768 0 soft N/A
medium 300 300 soft N/A
thumbnail 150 150 hard 1:1
Try an upload
We will create a test image of 3000 by 1500 pixels and import it, the same as an upload from the dashboard:
$ wp media import /tmp/banner.jpg –title="Banner" –porcelain
5
$ ls wp-content/uploads
banner-1-1024×512.jpg
banner-1-150×150.jpg
banner-1-1536×768.jpg
banner-1-2048×1024.jpg
banner-1-300×150.jpg
banner-1-768×384.jpg
banner-1-scaled.jpg
banner-1.jpg
banner-1024×512.jpg
banner-150×150.jpg
banner-1536×768.jpg
banner-2-1024×512.jpg
banner-2-150×150.jpg
banner-2-1536×768.jpg
banner-2-2048×1024.jpg
banner-2-300×150.jpg
banner-2-768×384.jpg
banner-2-scaled.jpg
banner-2.jpg
banner-2048×1024.jpg
banner-300×150.jpg
banner-768×384.jpg
banner-scaled.jpg
banner.jpg
$ wp post get 5 –fields=ID,post_title,post_type,post_mime_type,guid
Field Value
ID 5
post_title Banner
guid http://example.com/wp-content/uploads/banner-2.jpg
post_type attachment
post_mime_type image/jpeg
WordPress also made a file ending with -scaled. Images bigger than 2560 pixels are scaled down to that size, and the original is kept for you. The -150x150 and the other files are the generated sizes from the table above.
Rules for good images
- Resize the image before the upload. A 6000 pixel photo is not needed for a 800 pixel box.
- Write the Alt text for every image. It helps screen readers and search engines.
- Use clear file names, like
red-running-shoes.jpg, notIMG_4837.jpg. - Prefer modern formats like WebP or AVIF for photos when your host supports them.
Upload limit
Your host decides the maximum file size. WordPress tells you the number it can use:
$ wp eval 'echo size_format(wp_max_upload_size());'
2 MB
The number comes from the PHP settings of the server, so it is different on every host. If the limit is too small for you, ask the host or raise upload_max_filesize and post_max_size in the PHP settings.
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |