Set default attachment display settings, alignment, link to, size in wordpress

homepage builder

Have you ever wanted to change the default options when inserting media into a post? Setting the default alignment to "left" or the default size to "large" ? This may not appear to be a big deal but if you are constantly changing the settings to the same thing over and over again for each image this is a must have snippet. We are updating the options "image_default_align, image_default_link_type, image_default_size". Keep in mind that this just changes the default settings of these options within the add media popup. The method we use to update these options can be used for a number of other options including what you can find in this options reference.

function wps_attachment_display_settings() {
	update_option( 'image_default_align', 'left' );
	update_option( 'image_default_link_type', 'none' );
	update_option( 'image_default_size', 'large' );
add_action( 'after_setup_theme', 'wps_attachment_display_settings' );

Comments  Leave a Reply

  1. Are there similar update_option settings for the Gallery menu? I don’t see anything in the reference but I’d love to change the defaults for the Attachment, Columns, and Size settings there.

  2. What file should these be put in? wp_config.php? I followed the link to options reference and interestingly enough, they don’t say there either!

    1. KingSky, sorry I was not clear, you can just add this to the functions.php

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!