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.