I would also like to know if this is possible!
Hi
I have a solution to this, you need to edit the following file:
wp-admin/includes/media.php
Go to line 899
Change the line: $link = get_attachment_link($post->ID);
to
‘$link = wp_get_attachment_url($post->ID);’
This means that if either option is chosen the image will always link to the image url.
Then to line 914, simply delete this line, this removes the link to attachment button.
Let me know if this works for you.
It´s not a good idea make changes in WP´s core files. Instead, use the following code:
function custom_attachment_fields_to_edit($form_fields, $post) {
$form_fields["image_url"] = '';
$form_fields["url"] = '';
$form_fields["url"]["input"] = "hidden";
$form_fields["url"]["value"] = wp_get_attachment_url($post->ID);
return $form_fields;
}
add_filter("attachment_fields_to_edit", "custom_attachment_fields_to_edit", null, 2);
Hope it helps 🙂
Fantastic!
I had been trying to find the function to hook into but had no luck. For me this was a temporary solution to get clients started on the right foot (until an update wipes over the changes). I will try this out later, thanks again.
How do you force a search result (attachment) to link to file?