Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Created November 5, 2015 18:02
Show Gist options
  • Save blainerobison/c662cc262e989a3aaa76 to your computer and use it in GitHub Desktop.
Save blainerobison/c662cc262e989a3aaa76 to your computer and use it in GitHub Desktop.
Remove default link to media file when adding to WYSIWYG editor in WordPress
<?php
/**
* Remove Link When Adding Media
*
* Adding media to a WYSIWYG editor can sometimes automatically include a link
* to the file. This sets the default behavior for all users to none.
*
* @return void
*/
function prefix_media_linking() {
$setting = get_option( 'image_default_link_type' );
if ( $setting !== 'none' ) {
update_option( 'image_default_link_type', 'none' );
}
}
add_action( 'admin_init', 'prefix_media_linking', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment