How to Automatically Remove Default Image Links in WordPress

WordPress makes it super easy for you to upload images and create image galleries.

However, older versions of WordPress automatically linked the image to the media file.

In this article, we will show you how to automatically remove default image links in WordPress.

Removing default image links in WordPress

Note: WordPress no longer adds default image links when you upload images to your posts or pages. However, if you are still using an older version or see this behavior on your website, then you can try the following steps.

Why You Should Disable Default Image Links in WordPress

By default, WordPress links images to themselves. A user sees that the image is a link, clicks it and they are then taken to the image file.

From this page the user has two options: click the ‘back’ button in their browser or move on to another site.

Usually, it is the latter. It also affects your image SEO traffic because search engines could redirect users to the link used for the image instead of your post.

Overall, it creates a bad user experience and affects your site’s bounce rate.

One solution is that you simply select the option to disable the link each time, but it is not feasible because sometimes you simply forget.

Removing image link

Removing Default Image Link in WordPress

It is very simple to disable the default image linking behavior in WordPress. However, you’ll need to add some code to your WordPress website. If you have not done this before, then take a look at our guide on how to copy and paste code snippets in WordPress.

All you have to do is add this code snippet in your theme’s functions.php file or a site-specific plugin.

function wpb_imagelink_setup() {
	$image_set = get_option( 'image_default_link_type' );
	
	if ($image_set !== 'none') {
		update_option('image_default_link_type', 'none');
	}
}
add_action('admin_init', 'wpb_imagelink_setup', 10);

This code basically tells WordPress to update the image_default_link_type option and set it to ‘none’. This option is then stored in your WordPress database.

After adding this code, go ahead and add a new image in WordPress. You’ll notice that it no longer links to the image file or the attachment page.

Hopefully, this will make adding images in WordPress a little less annoying specially if you never link to images.

If you want to learn how to add links to an image or gallery images, then follow our guide on how to add custom links to gallery images in WordPress.

New WordPress users may also want to see our tutorial on how to add and align images in WordPress posts and pages.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.