WordPress Set File As Default Link To

A comic book site I edit uses a lot of images as you would imagine, but frequently contributors forget to set the Link To section of adding images. More often than not this means instead of readers getting a nice enlarged version of the image popping up on their computer it does nothing (Link To None) or goes to a new page showing the image at the same size (Link To Attachment Page). I’ve asked everyone to make sure this feature is set to Media File, but people are people. Until WordPress version 3.5 I was able to set this feature through options.php but that doesn’t seem to work anymore. Wandering around the internet I was able to piece together a solution, by adding the following to my functions.php file.

function cbd_imagelink_setup() {
$image_set = get_option( ‘image_default_link_type’ );
if ($image_set !== ‘file’) {
update_option(‘image_default_link_type’, ‘file’);
}
}
add_action(‘admin_init’, ‘cbd_imagelink_setup’, 10);

Name the function whatever you’d like or leave as is. It’s worked as advertised: all images are now linked to the file.