Introduce `attachment_url_to_postid` filter to let plugins manage the uploads location better.

Props mattwiebe. Fixes #31717.

git-svn-id: https://develop.svn.wordpress.org/trunk@31867 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-03-23 17:23:27 +00:00
parent 074eba3a53
commit fc1d327261
1 changed files with 10 additions and 0 deletions

View File

@ -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;
}