Home / admin / Set default attachment display settings, alignment, link to, size in wordpress
  • How to Set default attachment display settings, alignment, link to, size in wordpress

    attachment alignment admin menu

    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.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    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' );
    

    ( WordPress codex functions, hooks, in this snippet. )

    image_default_link_type, image_default_size, image_default_align, add_action, update_option, wp,
  • KingSky

    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!

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

  • Josh

    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.