Set Default Attachment Display Settings in WordPress

When the new media uploader was introduced back in WordPress 3.5, many awesome features were added that made adding images to your posts a whole lot easier. One thing that bugged me a little though I never really took the time to change was the default attachment display settings that appeared each time you opened the media uploader.
Recently a client requested I changed the default setting so I had to delve into the code to figure out just how to do that. Ends up being quite an easy little mod.
Just add the following code to your theme’s functions.php file:

add_action( 'after_setup_theme', 'default_attachment_display_settings' );
/**
 * Set the Attachment Display Settings "Link To" default to "none"
 *
 * This function is attached to the 'after_setup_theme' action hook.
 */
function default_attachment_display_settings() {
	update_option( 'image_default_align', 'left' );
	update_option( 'image_default_link_type', 'none' );
	update_option( 'image_default_size', 'large' );
}

Here are the options for each:
image_default_align

  • left
  • right
  • center
  • none

image_default_link_type

  • file
  • post
  • custom
  • none

image_default_size

  • thumbnail
  • medium
  • large
  • full

When it comes to the image_default_size, certain images won’t have every size so setting a default will be ignored if that specific images doesn’t have that size available.

Share this:

Email
Facebook
Twitter
Pinterest
Pocket

Premium Themes for WordPress

Looking for an easy-to-use Premium Theme for WordPress? Check out Themes by bavotasan.com and have your site up and running in no time.

Use this WordPress website builder to build powerful websites in no time for your or your clients.

WordPress Hosting

WP Engine – designed from the ground-up to support and enhance the workflow of web designers.

Bluehost – providing quality web hosting solutions since 1996.

About the author

Picture of Luke Perrie

Luke Perrie