Family Encyclopedia >> Electronics

How to Disable Default Image Links in WordPress Automatically

WordPress simplifies uploading images and building galleries, but its default behavior of linking images to their media files can disrupt user experience. While you can uncheck this option manually, it's easy to overlook. As experienced WordPress developers, we'll guide you through permanently disabling these links for smoother workflows and better SEO.

Why Disable Default Image Links in WordPress

WordPress automatically links images to their attachment pages. Users click expecting more context, only to reach a bare image file—prompting them to hit back or leave your site entirely. This spikes bounce rates and can dilute SEO efforts, as search engines may favor the image page over your content.

A manual fix works per image, but consistency relies on habit, which often falters.

How to Disable Default Image Links in WordPress Automatically

How to Remove Default Image Links in WordPress

Disabling this globally is straightforward. Add this proven code snippet to your active theme's functions.php file or a custom 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);

Alternatively, activate the 'No Image Link' plugin for an instant, no-config solution. That said, the code runs only once during admin init, making it more performant than a plugin that triggers on every page.

This change streamlines image handling—ideal if you rarely link directly to files. Do you intentionally link images? Let us know in the comments.

Source: Norcross