2

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.

  • 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
0

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)

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