diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 282e68a0c5..9c04e9c7ac 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -3409,6 +3409,16 @@ function attachment_url_to_postid( $url ) { ); $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; }