A pet peeve of mine, if you will. 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’.
$image_set = get_option( 'image_default_link_type' );
if (!$image_set == 'none') {
update_option('image_default_link_type', 'none');
}
{ 10 comments… read them below or add one }
YES. thank you
If this is an option, there’s no need for the update_option to be run on every page load, though, right?
Good point. I’ve updated the post to have it check the option value first, then only update if it isn’t ‘none’.
Andrew, would this work in Thesis too?
yep. framework agnostic.
This is the best post of the week! Thank you!
This was useful, thanks Andrew!
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';
}
hadn’t considered the filter route. thanks!
Sweet, thanks for that tip!