This has always been a pet peeve of mine. By default, WordPress will set the link to any image that you upload to the file itself. That’s great if you’re using some sort of LightBox setup, but 99% of the time you aren’t. It’s just the image. So if you forget to remove the link…..no dice.
Well, not if you add this handy line to your functions file
update_option('image_default_link_type', 'none');
Yep, that’s it.
** UPDATE 12/21/2011 **
Thanks to @mitcho for pointing out that we don’t need the option to update every time, only once. So here’s a slightly modified function to check the value first, then update if it isn’t set to ‘none’.
** UPDATE 06/19/2012 **
Seems that the release of WP 3.4 changed how the function operated (slightly). Take a look at the updated function below.
saracannon
YES. thank you
mitcho
If this is an option, there’s no need for the update_option to be run on every page load, though, right?
Norcross
Good point. I’ve updated the post to have it check the option value first, then only update if it isn’t ‘none’.
Avinash D'Souza
Andrew, would this work in Thesis too?
Norcross
yep. framework agnostic.
Brett Deaton
This is the best post of the week! Thank you!
Josh Hartman
This was useful, thanks Andrew!
Matt Wiebe
If you don’t want to actually set the option, you can just use a filter override to ensure it will never change back:
add_action('pre_option_image_default_link_type', 'always_link_images_to_none');function always_link_images_to_none() {
return 'none';
}
Norcross
hadn’t considered the filter route. thanks!
Susan
Sweet, thanks for that tip!
Jupiter Jim
I am sorry, I have tried both the modified code and the code using the filter by Matt Weibe. I’ve tried them both on my real site and my demo site. I click on images added by pasting the URL “the Thesis Way” and clicked on images that are just uploaded to the post.
I can tell you that sometimes it works and sometimes it doesn’t, even on the same site with different pics.
Very strange.
Anyone else with this problem?
BTW, I love this font. may I ask what it is?
Thanks!
~ Jupiter Jim
Norcross
Keep in mind this won’t affect any images that have already been posted, only those going forward. Also, this won’t affect anything using custom fields (Thesis or otherwise), but it should remove the default ‘link’ option when using the media uploader.
And the font is the Century Gothic font stack.
Luke Shield
Odd, this doesn’t seem to work on WordPress 3.4
It looks like they’ve changed the structure of the options.php file?
Norcross
I hadn’t looked closely at how this would work in 3.4. Let me see what’s up and I’ll update the tutorial accordingly.
Mo
Hi,
Thanks for the tip Norcross.
Have you been able to make it works on WP3.4 ?
For me it doesn’t work, tried the updated one 19 of june.
Thanks for your feedback
Mo
Norcross
I just checked again, and the updated function works. Keep in mind that this won’t affect any images already in posts, rather, only the actual media uploader process of adding the link. If your theme has some sort of auto-linking function, this wouldn’t change that.
Mo
Hi Nocross,
Thanks for the quick reply
I was also suspecting a theme issue, because haven’t found anyone complaining about this tip nor the others using the hidden options page 
I’m using the minimalist “core” theme http://themeforest.net/item/core-minimalist-photography-portfolio/240185 with images scroll on hompage and wanted to use images as Websites bookmarks, therefore would like to change image url to website link. Any Help Will be greatly appreciated …
Norcross
That would involve modifying the theme code itself. I have no clue how that theme itself is built. If you’d like to hire me to troubleshoot it, you can contact me using the contact form on my business website here
Mo
Thanks for the proposition, but I’m not sure it’s related to the theme. Yesterday I tried again with version 3.3 and the default theme (20/11), and and tried all the tips and I wasn’t able to to see that field editable at all. I really don’t know what’s wrong, could be something with OVH or the DB or file access rights…. I also checked the DB and the image type setting is clearly shown ‘none’.
I will continue my research and then maybe will contact for a private support. Thanks a million for sharing your knowledge and experiences
Dietrich
I updated option image_default_link_type to file. The url will be shown correctly, the link is changed to image file, but in the gallery setting attachment page stays activated and if I go to front end the thumbnail ist linked to the attachment file and not to the image. In wp_options database image_default_link_type is set do file.
What is wrong?
Dietrich
Norcross
This setting only applies to single images. You need to set the options in your gallery shortcode to display file instead of attachment URL. All the gallery shortcode options can be seen here: Gallery Shortcode – WordPress Codex
Andrew
Isn’t it quicker to simply set it every time rather than check if it’s set and then set if not?
Norcross
It’s really 6 one, half dozen the other. Running the check avoids an actual database write.
Kyle Theisen
Nice work. I posted something very similar a while back. The difference with mine is that it will link to everything but images. So if you upload a PDF, it keeps the link (problem some clients have).
https://forrst.com/posts/WordPress_Remove_link_from_uploaded_images_bu-Tz0
Aditya Pandey
Thanks you very much.
I just don’t know why WordPress have attachment page option, it really annoys me at least.
Some kind of plugin triggered to post image as attachment by default.
I solved it by using your function, changing “none” to “file”.
Thanks again.
Roezer
Works on the Origin Theme thanks, I found it annoying that Images would link to the file url good for scrapers and hotlinkers but not the rest of us is how I think of it.