Change default from “Attachment post URL” to “File URL” in Add Media

When a user upload images, by default, the Attachment Post URL option is selected. How can I change the default to be “File URL”? If that is not possible, how can I remove the attachment post url completely?

I made a Google search that brought more questionmarks than answers.

Read More

EDIT:

I found a way to disable the attachment post URL, this code works:

add_filter('attachment_fields_to_edit', 'my_attachment_fields_edit', 10, 2); 
function my_attachment_fields_edit($form_fields,$post){ 
    //Set attachment link to none and hide it.
    $html = "<input type='hidden' name='attachments[".$post->ID."][url]' value=''/>";

    $form_fields['url']['html'] = $html; //Replace html
    $form_fields['url']['label'] = ''; //Remove label
    $form_fields['url']['helps'] ='';//Remove help text

    return $form_fields;
}

However I am still looking for a way to change which one is set as default.

Related posts

Leave a Reply

1 comment

  1. Youre almost there. The func I show in this thread sets the ‘large’ as default, but also, in that thread, you’ll see

    There is a hidden options page in WordPress under yoursite.com/wp-admin/options.php On that endless list of undocumented options you can set a value for “image_default_link_type”. You may want to set it to “file” (without the quotes)