diff --git a/wp-includes/media.php b/wp-includes/media.php index 9ec6e47c43..2c426bf729 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3431,6 +3431,14 @@ function attachment_url_to_postid( $url ) { $dir = wp_upload_dir(); $path = $url; + $site_url = parse_url( $dir['url'] ); + $image_path = parse_url( $path ); + + //force the protocols to match if needed + if ( isset( $image_path['scheme'] ) && ( $image_path['scheme'] !== $site_url['scheme'] ) ) { + $path = str_replace( $image_path['scheme'], $site_url['scheme'], $path ); + } + if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) { $path = substr( $path, strlen( $dir['baseurl'] . '/' ) ); } @@ -3449,9 +3457,7 @@ function attachment_url_to_postid( $url ) { * @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; + return (int) apply_filters( 'attachment_url_to_postid', $post_id, $url ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index a5b2acc701..6a3efdb356 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-33704'; +$wp_version = '4.4-alpha-33705'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.