The following code will empty the Link URL
field when Full Size
button is clicked. And fill the same field with the File URL
value when other buttons are clicked.
Tested with WordPress 3.4.2. Drop the code in your theme’s functions.php
file or create a simple plugin for it.
add_action( 'admin_head-media-upload-popup', 'wpse_41539_add_remove_image_url' );
function wpse_41539_add_remove_image_url()
{
// Don't run if viewing "From URL" tab
if( 'type_url' != $_GET['tab'] )
{
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
/*
* If Full Image size selected, empty the URL field
*/
$(document).on('change','input[type="radio"][value="full"]',function(){
$(this).parent().parent().parent().parent()
.find('tr.url td.field button.urlnone').click();
});
/*
* If other image sizes selected, fill the URL field with the File URL
* Change "button.urlfile" to "button.urlpost" to use the Attachment Post URL
*/
$(document).on('change','input[type="radio"][value!="full"]',function(){
$(this).parent().parent().parent().parent()
.find('tr.url td.field button.urlfile').click();
});
});
</script>
<?php
}
}