Set attachment’s default “Link To” value

attachment-display-settings When inserting an attachment into a WordPress post, we can customize how it should be displayed. There are three settings; Alignment, Link To and Size. Here’s how we can tell WordPress to select None as the default value of Link To:

/**
 * Set default media link to 'none'
 *
 * @param   string $value Option value
 * @wp_hook filter pre_option_image_default_link_type
 * @return  string
 */
function _kucrut_image_default_link_type( $value ) {
    return 'none';
}
add_filter( 'pre_option_image_default_link_type', '_kucrut_image_default_link_type' );

As of WordPress 4.0, there are four values available: file (default), post, custom and none.

Set attachment’s default “Link To” value

One thought on “Set attachment’s default “Link To” value

  1. Thank you, that helped a lot.. though I think it supposed to be like that by the default WordPress core. I always change it to none manually. and sometimes if I leave it as it is it breaks my image alignment, since the CSS styling will consider it as an <a> tag.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.