Default WordPress image link URL to “file URL”
I like using the WordPress plugin “Fancybox” to add clean fly out effects to images, PDFs, and YouTube videos. I noticed depending on the theme I was using sometimes you would click a newly inserted image and FancyBox worked other times it took you to an attachments page for the image. That’s when it hit me. For FancyBox to function correctly the link to the image has to be set as “file URL”. It also dawned on me that some of my themes defaulted to “file URL” while others defaulted to “attachment URL”
To set your default image link URL to “file” add the bit of code below to your functions.php file.
update_option('image_default_link_type','file');
(Via WordPress Forum link Submitted by Adam Capriola)