2 tested
source | link

You can define a function to remove the protocol and hook it to the attachment URL:

function myRemoveProtocolwpse_79958_remove_protocol_from_attachment($url) {
    $url = str_replace(array('http:', 'https:'), '', $url);
    return $url;
}
add_filter( 'attachment_link', 'myRemoveProtocol''wpse_79958_remove_protocol_from_attachment' );

Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative:

add_filter( 'attachment_link', 'wp_make_link_relative' );

Place this code to your functions.php. Not tested though.

Update: already tested

You can define a function to remove the protocol and hook it to the attachment URL:

function myRemoveProtocol($url) {
    $url = str_replace(array('http:', 'https:'), '', $url);
    return $url;
}
add_filter( 'attachment_link', 'myRemoveProtocol' );

Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative:

add_filter( 'attachment_link', 'wp_make_link_relative' );

Place this code to your functions.php. Not tested though.

You can define a function to remove the protocol and hook it to the attachment URL:

function wpse_79958_remove_protocol_from_attachment($url) {
    $url = str_replace(array('http:', 'https:'), '', $url);
    return $url;
}
add_filter( 'attachment_link', 'wpse_79958_remove_protocol_from_attachment' );

Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative:

add_filter( 'attachment_link', 'wp_make_link_relative' );

Place this code to your functions.php. Not tested though.

Update: already tested

1
source | link

You can define a function to remove the protocol and hook it to the attachment URL:

function myRemoveProtocol($url) {
    $url = str_replace(array('http:', 'https:'), '', $url);
    return $url;
}
add_filter( 'attachment_link', 'myRemoveProtocol' );

Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative:

add_filter( 'attachment_link', 'wp_make_link_relative' );

Place this code to your functions.php. Not tested though.