Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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.

share|improve this question
    
From some Answers here and looking at the core (wp-admin/includes/media.php), seems that's not possible. The linked search query only return 7 results, take a look to see if you can extract something from those. –  brasofilo Oct 24 '12 at 12:52
add comment

1 Answer

up vote 0 down vote accepted

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)

share|improve this answer
add comment

protected by Community Apr 27 '13 at 6:29

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.