Images and other media files are an important part of any WordPress website. To utilise them effectively, it helps to have a house grasp on how the WordPress media library works.

This handy WordPress feature enables yous to store and manage your images and other media over fourth dimension. With some insider knowledge and a few simple tricks, at that place's a lot yous can do to improve your site via your Media Library.

In this comprehensive guide, we'll walk you lot through everything there is to know about the WordPress Media Library, including how to import and download content. Nosotros'll besides cover paradigm editing, long-term file management, and four hacks for incorporating advanced functionality.

Let's become started!

An Introduction to the WordPress Media Library

At its cadre, your WordPress Media Library is exactly what its name implies: a catalog of all the media files yous've uploaded to your site:

WordPress Media Library
WordPress Media Library

WordPress is capable of hosting a variety of types of media, including:

  • Images (.jpg, .jpeg, .png, .gif, and .ico).
  • Audio files (.mp3, .m4a, .ogg, and .wav).
  • Videos (.mp4, .m4v, .mov, .wmv, .avi, .mpg, .ogv, .3gp, and .3g2).
  • PDFs.
  • Word documents.
  • Excel spreadsheets.
  • PowerPoint presentations.
  • Adobe Photoshop documents.

Information technology also has some limited photograph-editing capabilities, so y'all can brand adjustments as needed right from your dashboard.

Unfortunately, WordPress doesn't support webp images out of the box nevertheless.

To access your Media Library, merely click on Media in your admin sidebar at any fourth dimension:

Accessing the WordPress Media Library
Accessing WordPress Media Library

In that location are a few basic options available here.

Beginning, you can decide if you want to run into your files in a list or grid view by clicking on the relevant icons:

WordPress Media Library view options
WordPress Media Library view options

You tin can also filter your files using the drop-down menus:

Filtering WordPress Media Library files
Filtering WordPress Media Library files

The first menu enables yous to view your media by type, while the 2nd will filter your library's contents by the dates on which they were uploaded.

You can as well utilise the search bar to wait for specific files by name:

WordPress Media Library search bar
WordPress Media Library search bar

Finally, there's besides a Bulk Select button. This feature lets yous delete several files from your WordPress installation all at once:

Bulk select option in the WordPress Media Library
Bulk select option in the WordPress Media Library

This covers all of the native functionality available in the WordPress Media Library screen.

As y'all'll encounter later, there are many modifications you tin can make to enhance it. First, however, nosotros demand to discuss how to add files to WordPress.

✨ Images are powerful means to sell and appoint with your users. Larn everything you lot demand to know about the WordPress Media Library 📸 Click to Tweet

How to Add Files to Your WordPress Media Library

At that place are a few different means you can add files (e. m. your site's favicon) to your WordPress Media Library. The first is to navigate to Media > Add New:

Accessing the WordPress Media Uploader
Accessing the WordPress Media Uploader

Here, you tin upload files that are saved on your computer or another device:

WordPress Media Uploader
WordPress Media Uploader

You can also add media directly from the WordPress editor. In the Cake Editor, start past adding the corresponding block for the type of media yous want to comprise:

WordPress media blocks
WordPress media blocks

In the resulting placeholder, select Upload and choose a file from your computer:

Block editor upload
Uploading media from the Block Editor

Alternatively, you can simply drag and drop the file from your desktop into the relevant cake.

In the Archetype Editor, you'll need to click on the Add Media button:

Classic Editor Add Media button
Classic Editor Add Media push button

And then navigate to the Upload tab and select a file from your calculator:

Uploading media from the Classic Editor
Uploading media from the Classic Editor

Yous can also drag and drib files from your desktop direct into the editor at any fourth dimension.

In some cases, you lot may find that you need to manually upload media files to your WordPress site via FTP. You tin do this using a client such as FileZilla.

Once you connect to your server, navigate to wp-content > uploads:

ftp uploads
Uploading files to WordPress Media Library directory via FileZilla

Upload files to this directory to add together them to your Media Library.

Downloading Content from the WordPress Media Library

In some circumstances, you may need to download files from your Media Library onto your computer. WordPress enables y'all to do this natively by navigating to Tools > Export:

WordPress export tool
WordPress export tool

Then select the Media option. If you just need files that were uploaded within a specific time frame, you can utilise the dropdown menus to specify your request:

Exporting WordPress media
Exporting WordPress media

Finally, click on the Download Export File push button. This will download the relevant media files to your computer.

How to Edit Images in the WordPress Media Library

As we mentioned earlier, WordPress has a few native image editing features. To access them, navigate to your WordPress Media Library and select the file you lot desire to edit. Then, click on the Edit image push:

edit image button
Edit Paradigm button in WordPress

This will open the epitome editor:

wordpress image editor
WordPress image editor

In that location are five basic edits y'all can make:

Cropping enables you lot to cut sections of the image out:

wordpress image crop
Paradigm crop in WordPress

Rotating the image volition plough information technology either counterclockwise or clockwise past xc degrees:

wordpress image rotate
Image rotate left in WordPress

Flipping the image volition reflect it either vertically or horizontally:

wordpress image flip
Image horizontal flip in WordPress

The other three settings are in the sidebar. The first enables you lot to change the size of the prototype by scaling it. Only enter your desired meridian or width, and the other field will auto-populate. And so click on the Scale push:

wordpress image scale
Scaling an epitome in WordPress

It'south of import to notation that resizing images in WordPress can sometimes negatively bear upon their quality.

Additionally, you can only take large images and scale them down. You can't scale images upward to a larger size!

To crop your image so that it has a specific aspect ratio or dimensions, you can utilize the Attribute Ratio and Choice fields under Image Crop:

image crop selection
Setting the image crop selection dimensions in WordPress

Finally, if yous wish to preserve the existing image thumbnail, you can do so using the Thumbnail Settings. But select the radio button for whichever version of your epitome you want to use changes to:

wordpress thumbnail edit settings
Thumbnail settings in the WordPress prototype editor

WordPress' default image editing is useful merely limited. It won't supersede any software you might apply for more extensive modifications, especially if you're running a photography site or photoblog.

Understanding WordPress Media Library Errors

Unfortunately, WordPress errors occur. And the WordPress Media Library is no exception.

Subscribe Now

One issue that usually shows upwardly is an unspecified "HTTP error" that tin appear when you're uploading a new file from within the editor:

media http error
HTTP mistake on media upload

Normally, y'all can merely wait for this error to disappear and endeavour your upload again after a few minutes. If the HTTP error reoccurs, it may exist that your WordPress session has expired. Y'all'll demand to log in again and and so retry your upload.

Some other problem some users face is the Media Library failing to load. This is ofttimes due to a disharmonize with your plugins and/or theme. To troubleshoot this error, endeavor deactivating all of your plugins and switching to a WordPress default theme.

If your Media Library loads properly again, you'll need to troubleshoot the plugin conflict further in order to resolve the issue permanently.

Sometimes you can encounter the "Upload: Failed to Write File to Disk" error when y'all get-go uploading your files through the media library. Commonly, this problem occurs when your upload directory is set to Not Writable. You can bank check your filesystem permissions via WordPress's Site Health tool.

Long-Term Media Library Management

So far, we've focused exclusively on WordPress' native functionality when it comes to the Media Library. Still, as y'all apply this feature over fourth dimension, yous'll probable run into some trouble that requires help from external solutions.

For example, the more files you add, the more than disorganized your WordPress Media Library will become. Aside from the search and filter options discussed towards the beginning of this post, WordPress doesn't provide much help for dealing with unruly volumes of media.

In that location are, nevertheless, a few plugins that enable you to arrange your media files into folders.

WordPress Media Library Folders plugin is the nearly popular option:

WordPress Media Library Folders WordPress plugin
WordPress Media Library Folders WordPress plugin

In addition to enabling you lot to create media file folders, this plugin also integrates with MaxGalleria to allow you create image galleries straight from the Media Library:

WordPress Gallery MaxGalleria WordPress plugin
WordPress Gallery MaxGalleria WordPress plugin

Upgrading to WordPress Media Library Folders Pro provides additional integration with the NextGEN Gallery plugin and Advanced Custom Fields. It also enables you to create categories and tags to farther organize your files.

Another functionality WordPress lacks is the ability to supervene upon media files with new versions. Since these types of files can exist quite large, you lot don't want to simply keep adding new ones whenever you need to update your content.

This means that after uploading a new file, you'll demand to locate the sometime version and delete it. Yous can save yourself some fourth dimension by directly replacing old images with Enable Media Supersede by ShortPixel:

Enable Media Replace WordPress plugin
Enable Media Replace WordPress plugin

With this plugin, you tin can also supercede all links pointing to the former file. This is helpful for fugitive broken media throughout your site.

Real Media Library is another folders and files managing director worth checking out to make your file direction a breeze.

Real Media Library WordPress plugin
Real Media Library WordPress plugin

Thanks to it, y'all're able to take intendance of plenty of files such equally pictures, videos, and documents direct in WordPress. Overnice thing to know: Real Media Library is available in 12 languages. If the gratis version isn't enough for your needs, they as well provide a buy the PRO version with more than features.

iv Handy WordPress Media Library Hacks

The WordPress Media Library can handle most of the common requirements of a site administrator. Nevertheless, WordPress provides a number of functions and hooks that enable users to enhance specific features of the Media Library, without the use of third-political party plugins. Let'south swoop into these functions and hooks with four practical examples.

1. Add Custom Metadata to Attachment Mail service Types

Whatever time y'all upload a media file, WordPress generates an zipper post type.

But like whatever other post blazon, attachments are registered in the wp_posts table, and their respective metadata can exist establish in the wp_postmeta table in your database:

wordpress attachment details
Default attachment details panel

The wp_posts tabular array stores data that includes post_content (attachment clarification), post_excerpt (zipper caption), post_author, post_title, post_status, and post_mime_type.

The wp_postmeta table stores any kind of metadata, such equally the attached file URL, prototype dimensions and mime types, and Exchangeable Paradigm File format (EXIF) and International Printing Telecommunications Council (IPTC) metadata.

You may occasionally need to add custom metadata to attachments, such as the name of the writer of a certificate, an associated URL, or the location where a photo was taken. Adding meta fields to attachments is a bit different from calculation meta fields to posts, and requires specific hooks and functions.

Starting time, you lot'll demand to add all necessary custom fields to the Edit Media screen. Yous can accomplish this chore by filtering the available attachment fields through the attachment_fields_to_edit filter in wp-admin/includes/media.php:

          part media_hacks_attachment_field_to_edit( $form_fields, $post ){  	// https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata 	$media_author = get_post_meta( $post->ID, 'media_author', true );      	$form_fields['media_author'] = assortment( 		'value' => $media_author ? $media_author : '', 		'label' => __( 'Author' ) 	);  	return $form_fields; } add_filter( 'attachment_fields_to_edit', 'media_hacks_attachment_field_to_edit', 10, 2 );        

The function has two arguments: the $form_fields array of form fields and the $postal service object. First, get_post_meta retrieves the existing 'media_author' value, then a 'media_author' element is added to the $form_fields array.

Finally, the callback returns $form_fields (encounter the code on Gist).

This will brandish a new field on the Edit Media page, which y'all tin can access by selecting the relevant image from your Media Library and clicking on the Edit more than details link:

edit more details
Accessing WordPress Edit Media folio

On the resulting screen, you lot'll see your new custom metadata field at the bottom:

New "author" metadata field
New "author" metadata field

The side by side stride is saving the user input. You can accomplish this by hooking a new function to the edit_attachment activity:

          function media_hacks_edit_attachment( $attachment_id ){ 	if ( isset( $_REQUEST['attachments'][$attachment_id]['media_author'] ) ) {      		$media_author = $_REQUEST['attachments'][$attachment_id]['media_author'];      		update_post_meta( $attachment_id, 'media_author', $media_author ); 	} } add_action( 'edit_attachment', 'media_hacks_edit_attachment' );                  

This role keeps just one argument: the $attachment_id of the current media file. Commencement, the office checks to see whether a valid value for the custom meta field has been sent. And then it registers the value thanks to the update_post_meta part (see the code on Gist).

Now, you tin recall the 'media_author' value thanks to the get_post_meta office:

          $media_author = get_post_meta( $post->ID, 'media_author', true );        

Later on that, you lot tin display it anywhere in the frontend.

2. Display EXIF and IPTC Metadata in the Edit Media Screen

WordPress automatically stores extended metadata for JPEG and TIFF mime types. Now that you lot know how to add fields to the Edit Media screen via media.php, you lot tin can display this data.

To accomplish this task, yous have to modify the first callback function as follows:

          office media_hacks_attachment_fields_to_edit( $form_fields, $post ){  	// get postal service mime blazon 	$type = get_post_mime_type( $mail service->ID );  	// go the attachment path 	$attachment_path = get_attached_file( $post->ID );  	// go image metadata 	$metadata = wp_read_image_metadata( $attachment_path );  	if( 'image/jpeg' == $type ){  		if( $metadata ) {  			$exif_data = array( 				'discontinuity'          => 'Aperture',  				'camera'            => 'Camera',  				'created_timestamp' => 'Timestamp', 				'focal_length'      => 'Focal Length',  				'iso'               => 'ISO',  				'shutter_speed'     => 'Exposure Time',  				'orientation'       => 'Orientation' );  			foreach ( $exif_data as $primal => $value ) {  				$exif = $metadata[$key]; 				$form_fields[$key] = array( 					'value' => $exif ? $exif : '', 					'label' => __( $value ), 					'input' => 'html', 					'html'  => "ID][$exif]' value='" . $exif . "' /> 				); 			} 		} 	} 	return $form_fields; } add_filter( 'attachment_fields_to_edit', 'media_hacks_attachment_fields_to_edit', 10, two );        

This snippet uses the following WordPress functions:

  • get_post_mime_type retrieves the mime type of an attachment based on the ID.
  • get_attached_file retrieves the attached file path based on the ID.
  • wp_read_image_metadata gets EXIF or IPTC metadata, if bachelor.

If prototype mime type is "prototype/jpeg", and if metadata exists, then an array of required metadata is alleged, and a course field for each element in the array is created:

exif iptc metadata
EXIF and IPTC metadata fields in WordPress attachment details

The form fields of this example are a bit more complex, every bit we're setting a value for the 'html' course element (see the code on Gist). You don't need to save EXIF and IPCT metadata, as WordPress automatically stores them into the wp_postmeta table when uploading images.

3. Prove Extended Metadata on the Frontend

Having all of this information for yourself on the back stop is useful. However, if you lot also want to testify extended metadata for your media files on the frontend, you lot'll demand to exercise a piffling more than tinkering.

To exercise so, y'all can append this information to the zipper description using a the_content filter in wp-admin/includes/post.php, similar so:

          office media_hacks_the_content( $content ){ 	global $post;  	if( is_attachment() && 'image/jpeg' == get_post_mime_type( $post->ID ) ) {  		$fields = wp_get_attachment_metadata( $post->ID ); 		$meta = $fields['image_meta'];  		if( ! empty( $meta['camera'] ) ){ 			$custom_content = " 			<ul> 				<li>Camera: {$meta['photographic camera']}</li> 				<li>Created timestamp: {$meta['created_timestamp']}</li> 				<li>Aperture: {$meta['aperture']}</li> 				<li>Focal length: {$meta['focal_length']}</li> 				<li>ISO: {$meta['iso']}</li> 				<li>Shutter speed: {$meta['shutter_speed']}</li> 				<li>Orientation: {$meta['orientation']}</li> 			</ul>"; 			$content .= $custom_content;  		} 	} 	return $content; } add_filter( 'the_content', 'media_hacks_the_content' );        

Here, the wp_get_attachment_metadata function is chosen. If the current post type is "attachment", and if the current mime type is "prototype/jpeg", and so the available image metadata is retrieved and used to build an unordered listing of fields, which is appended to the mail content.

The callback function returns $content (see this code on Gist):

front end metadata
EXIF and IPTC metadata displayed on an zipper page

Above you tin can see the new attachment post with the metadata appended to the description.

four. Publish a Photo Archive

Out of the box, WordPress does not display archives of attachments. This happens considering the has_archive selection of the attachment postal service type is set to false.

Moreover, while the default post_status parameter of the $query object is set to"publish", the default zipper post_status is set to "inherit". This means that no attachments will be shown in archives unless we explicitly set the query post_status to "inherit" or "any" (see WP_Query Blazon Parameters for further information).

With that being said, in order to show image athenaeum, yous accept to define two functions. The first function filters the arguments of a specified post type, and sets the attachment has_archive property to true:

          function media_hacks_register_post_type_args( $args, $post_type ){ 	if( $post_type == 'zipper' ){ 		$args['has_archive'] = true; 	} 	return $args; } add_filter( 'register_post_type_args', 'media_hacks_register_post_type_args', 10, 2 );        

The second office sets custom values for the post_mime_type and post_status query variables:

          function media_hacks_pre_get_posts( $query ){ 	if ( !is_admin() && $query->is_main_query() ) {  		if( is_post_type_archive('attachment') ){ 			$query->prepare('post_mime_type', 'image/jpeg'); 			$query->set( 'post_status', 'inherit' ); 		} 	} } add_action( 'pre_get_posts', 'media_hacks_pre_get_posts' );                  

The function is hooked to the pre_get_posts action hook, which is fired after the query has been created, but before it's executed. The $query object is passed by reference, not by value, which means that whatever changes to the electric current instance of $query volition bear on the original $query object.

For this reason, it's important to verify which query yous're going to change (see this lawmaking on Gist). Then if you enter https://yourdomain.com/?post_type=attachment in your browser, you should run across an annal of JPEG images:

image archive page
WordPress Media Archive

The full code for all of these hacks is available every bit a plugin in a public Gist, which we've linked to through this section. Yous can download it as a .zip file and upload it to your WordPress site to implement all four of these hacks, without having to edit your files manually.

A film is worth 1,000 words...but merely if y'all know how to import, edit, and manage it in your WordPress site. 🖼 Click to learn more in this in-depth guide 📸 Click to Tweet

Summary

Images, videos, audio files, and documents can be extremely valuable to your site'due south users. The WordPress Media Library is essential to uploading, publishing, and even modifying these files in order to meet the needs of your content.

Do you have any other questions about the WordPress Media Library? Let u.s. know in the comments department below!


Salvage time, costs and maximize site performance with:

  • Instant assistance from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience reach with 29 information centers worldwide.
  • Optimization with our congenital-in Application Performance Monitoring.

All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to observe the programme that's right for y'all.