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

This handy WordPress feature enables you to store and manage your images and other media over time. With some insider knowledge and a few elementary tricks, at that place's a lot you lot can practise to ameliorate your site via your Media Library.

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

Let's get started!

An Introduction to the WordPress Media Library

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

WordPress Media Library
WordPress Media Library

WordPress is capable of hosting a diverseness 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.

It as well has some limited photo-editing capabilities, so you can make adjustments as needed right from your dashboard.

Unfortunately, WordPress doesn't back up webp images out of the box yet.

To access your Media Library, simply click on Media in your admin sidebar at any time:

Accessing the WordPress Media Library
Accessing WordPress Media Library

There are a few basic options bachelor here.

First, you can decide if you want to see your files in a listing or grid view by clicking on the relevant icons:

WordPress Media Library view options
WordPress Media Library view options

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

Filtering WordPress Media Library files
Filtering WordPress Media Library files

The commencement menu enables you to view your media by blazon, while the 2d volition filter your library's contents past the dates on which they were uploaded.

You lot tin can also use the search bar to await for specific files past name:

WordPress Media Library search bar
WordPress Media Library search bar

Finally, there'southward also a Bulk Select button. This characteristic lets y'all delete several files from your WordPress installation all at once:

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

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

As you'll see afterwards, at that place are many modifications you can make to heighten information technology. First, however, we need to discuss how to add files to WordPress.

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

How to Add together Files to Your WordPress Media Library

There are a few different means you can add files (e. k. your site's favicon) to your WordPress Media Library. The get-go is to navigate to Media > Add New:

Accessing the WordPress Media Uploader
Accessing the WordPress Media Uploader

Here, you lot tin can upload files that are saved on your estimator or another device:

WordPress Media Uploader
WordPress Media Uploader

Y'all can also add media directly from the WordPress editor. In the Cake Editor, start past calculation the corresponding block for the blazon of media you want to incorporate:

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, y'all tin can simply drag and drop the file from your desktop into the relevant block.

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

Classic Editor Add Media button
Classic Editor Add together Media button

Then navigate to the Upload tab and select a file from your estimator:

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

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

In some cases, y'all may observe that you lot need to manually upload media files to your WordPress site via FTP. You can 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, y'all may need to download files from your Media Library onto your computer. WordPress enables you to do this natively by navigating to Tools > Export:

WordPress export tool
WordPress export tool

Then select the Media option. If you only demand files that were uploaded inside a specific time frame, you can apply the dropdown menus to specify your request:

Exporting WordPress media
Exporting WordPress media

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

How to Edit Images in the WordPress Media Library

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

edit image button
Edit Image push in WordPress

This will open up the image editor:

wordpress image editor
WordPress image editor

There are five bones edits you can make:

Cropping enables you to cut sections of the image out:

wordpress image crop
Image crop in WordPress

Rotating the epitome volition plow it either counterclockwise or clockwise past 90 degrees:

wordpress image rotate
Prototype rotate left in WordPress

Flipping the image volition reverberate information technology either vertically or horizontally:

wordpress image flip
Image horizontal flip in WordPress

The other 3 settings are in the sidebar. The first enables you to change the size of the paradigm by scaling it. But enter your desired height or width, and the other field volition auto-populate. And so click on the Scale button:

wordpress image scale
Scaling an image in WordPress

Information technology's important to note that resizing images in WordPress can sometimes negatively bear upon their quality.

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

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

image crop selection
Setting the epitome crop pick dimensions in WordPress

Finally, if y'all wish to preserve the existing epitome thumbnail, you tin do so using the Thumbnail Settings. But select the radio push for whichever version of your image you want to apply changes to:

wordpress thumbnail edit settings
Thumbnail settings in the WordPress epitome editor

WordPress' default prototype editing is useful merely express. It won't replace any software you might employ for more extensive modifications, especially if you're running a photography site or photoblog.

Agreement WordPress Media Library Errors

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

Subscribe Now

I consequence that commonly shows up is an unspecified "HTTP error" that tin appear when you lot're uploading a new file from inside the editor:

media http error
HTTP error on media upload

Usually, you tin simply wait for this error to disappear and effort your upload once more after a few minutes. If the HTTP error reoccurs, information technology may be that your WordPress session has expired. You'll need to log in again and and then retry your upload.

Some other problem some users face is the Media Library failing to load. This is oft due to a conflict with your plugins and/or theme. To troubleshoot this mistake, try 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 farther in guild to resolve the issue permanently.

Sometimes you can run into the "Upload: Failed to Write File to Deejay" error when you start uploading your files through the media library. Usually, this trouble occurs when your upload directory is set to Not Writable. You tin can check your filesystem permissions via WordPress's Site Health tool.

Long-Term Media Library Management

And then far, we've focused exclusively on WordPress' native functionality when it comes to the Media Library. However, as you use this feature over time, you'll likely run into some trouble that requires assistance from external solutions.

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

There are, however, a few plugins that enable y'all to adjust your media files into folders.

WordPress Media Library Folders plugin is the nearly popular choice:

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

In addition to enabling you to create media file folders, this plugin also integrates with MaxGalleria to permit you create image galleries directly 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 Avant-garde Custom Fields. Information technology likewise enables you to create categories and tags to further organize your files.

Another functionality WordPress lacks is the ability to replace media files with new versions. Since these types of files tin can be quite big, yous don't want to simply keep adding new ones whenever y'all demand to update your content.

This means that after uploading a new file, you'll need to locate the sometime version and delete it. You can salvage yourself some time by directly replacing one-time images with Enable Media Supercede by ShortPixel:

Enable Media Replace WordPress plugin
Enable Media Replace WordPress plugin

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

Real Media Library is another folders and files manager worth checking out to brand your file direction a breeze.

Real Media Library WordPress plugin
Real Media Library WordPress plugin

Thanks to it, yous're able to have care of plenty of files such every bit pictures, videos, and documents directly in WordPress. Nice thing to know: Real Media Library is bachelor in 12 languages. If the free version isn't enough for your needs, they besides provide a buy the PRO version with more features.

four Handy WordPress Media Library Hacks

The WordPress Media Library tin can handle most of the mutual requirements of a site administrator. However, WordPress provides a number of functions and hooks that enable users to enhance specific features of the Media Library, without the utilise of third-party plugins. Let's dive into these functions and hooks with 4 practical examples.

1. Add Custom Metadata to Attachment Post Types

Whatever time you upload a media file, WordPress generates an zipper post type.

Just like any other post type, attachments are registered in the wp_posts table, and their respective metadata can be plant in the wp_postmeta table in your database:

wordpress attachment details
Default zipper details panel

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

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

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

Starting time, you'll need to add all necessary custom fields to the Edit Media screen. You lot can accomplish this task 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', truthful );      	$form_fields['media_author'] = assortment( 		'value' => $media_author ? $media_author : '', 		'characterization' => __( 'Writer' ) 	);  	render $form_fields; } add_filter( 'attachment_fields_to_edit', 'media_hacks_attachment_field_to_edit', 10, 2 );        

The function has 2 arguments: the $form_fields assortment of form fields and the $postal service object. Get-go, 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 (see the lawmaking on Gist).

This will display a new field on the Edit Media folio, which you tin access by selecting the relevant image from your Media Library and clicking on the Edit more details link:

edit more details
Accessing WordPress Edit Media folio

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

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

The next pace is saving the user input. You can attain this past hooking a new role to the edit_attachment action:

          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 office keeps just one argument: the $attachment_id of the current media file. Offset, the office checks to see whether a valid value for the custom meta field has been sent. And then it registers the value thank you to the update_post_meta function (meet the lawmaking on Gist).

Now, you can think the 'media_author' value thanks to the get_post_meta function:

          $media_author = get_post_meta( $postal service->ID, 'media_author', truthful );        

After that, you can 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 know how to add fields to the Edit Media screen via media.php, you tin can display this information.

To accomplish this job, y'all have to change the first callback function as follows:

          function media_hacks_attachment_fields_to_edit( $form_fields, $post ){  	// go post mime type 	$blazon = get_post_mime_type( $mail service->ID );  	// become the attachment path 	$attachment_path = get_attached_file( $mail->ID );  	// get image metadata 	$metadata = wp_read_image_metadata( $attachment_path );  	if( 'image/jpeg' == $type ){  		if( $metadata ) {  			$exif_data = array( 				'aperture'          => 'Aperture',  				'camera'            => 'Photographic camera',  				'created_timestamp' => 'Timestamp', 				'focal_length'      => 'Focal Length',  				'iso'               => 'ISO',  				'shutter_speed'     => 'Exposure Time',  				'orientation'       => 'Orientation' );  			foreach ( $exif_data as $key => $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, 2 );        

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 fastened file path based on the ID.
  • wp_read_image_metadata gets EXIF or IPTC metadata, if bachelor.

If image mime type is "image/jpeg", and if metadata exists, then an array of required metadata is declared, 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 grade fields of this example are a fleck more complex, equally we're setting a value for the 'html' form element (see the lawmaking on Gist). You don't need to relieve EXIF and IPCT metadata, equally WordPress automatically stores them into the wp_postmeta tabular array when uploading images.

iii. Show Extended Metadata on the Frontend

Having all of this data for yourself on the back cease is useful. However, if you also want to testify extended metadata for your media files on the frontend, you lot'll need to do a piddling more tinkering.

To do so, you can append this information to the attachment description using a the_content filter in wp-admin/includes/post.php, similar so:

          function 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>Photographic camera: {$meta['camera']}</li> 				<li>Created timestamp: {$meta['created_timestamp']}</li> 				<li>Discontinuity: {$meta['discontinuity']}</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;  		} 	} 	render $content; } add_filter( 'the_content', 'media_hacks_the_content' );        

Here, the wp_get_attachment_metadata function is called. If the current post blazon is "attachment", and if the current mime type is "image/jpeg", then the bachelor image metadata is retrieved and used to build an unordered listing of fields, which is appended to the post content.

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

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

Above yous can see the new attachment post with the metadata appended to the clarification.

4. Publish a Photo Archive

Out of the box, WordPress does not display archives of attachments. This happens considering the has_archive choice of the attachment post type is fix to imitation.

Moreover, while the default post_status parameter of the $query object is ready to"publish", the default attachment post_status is fix to "inherit". This means that no attachments will exist shown in athenaeum unless we explicitly gear up the query post_status to "inherit" or "any" (meet WP_Query Type Parameters for farther information).

With that existence said, in order to show image archives, you have to define ii functions. The commencement role filters the arguments of a specified postal service blazon, and sets the attachment has_archive belongings to true:

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

The second function 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('zipper') ){ 			$query->set('post_mime_type', 'epitome/jpeg'); 			$query->set( 'post_status', 'inherit' ); 		} 	} } add_action( 'pre_get_posts', 'media_hacks_pre_get_posts' );                  

The role is hooked to the pre_get_posts action claw, which is fired later on the query has been created, simply earlier it'due south executed. The $query object is passed by reference, not past value, which means that whatsoever changes to the current instance of $query will affect the original $query object.

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

image archive page
WordPress Media Archive

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

A movie is worth 1,000 words...but only if you lot know how to import, edit, and manage information technology in your WordPress site. 🖼 Click to larn more in this in-depth guide 📸 Click to Tweet

Summary

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

Do you accept whatever other questions about the WordPress Media Library? Let us know in the comments section beneath!


Save time, costs and maximize site performance with:

  • Instant help 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 than, in one programme with no long-term contracts, assisted migrations, and a 30-day-money-dorsum-guarantee. Check out our plans or talk to sales to find the programme that's right for you.