Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 31835)
+++ wp-includes/media.php	(working copy)
@@ -3409,6 +3409,16 @@
 	);
 	$post_id = $wpdb->get_var( $sql );
 
+	/**
+	 * Filter an attachment id found by URL.
+	 *
+	 * @since 4.2.0
+	 *
+	 * @param int|null $post_id  The post_id (if any) found by the function.
+	 * @param string   $url      The URL being looked up.
+	 */
+	$post_id = apply_filters( 'attachment_url_to_postid', $post_id, $url );
+
 	return (int) $post_id;
 }
 
