diff -r 48c4eec2b7e6 -r 8c2e4d02f4ef wp/wp-includes/canonical.php --- a/wp/wp-includes/canonical.php Fri Sep 05 18:40:08 2025 +0200 +++ b/wp/wp-includes/canonical.php Fri Sep 05 18:52:52 2025 +0200 @@ -553,16 +553,17 @@ $attachment_id = get_query_var( 'attachment_id' ); $attachment_post = get_post( $attachment_id ); $attachment_parent_id = $attachment_post ? $attachment_post->post_parent : 0; + $attachment_url = wp_get_attachment_url( $attachment_id ); - $attachment_url = wp_get_attachment_url( $attachment_id ); if ( $attachment_url !== $redirect_url ) { /* - * If an attachment is attached to a post, it inherits the parent post's status. Fetch the - * parent post to check its status later. - */ + * If an attachment is attached to a post, it inherits the parent post's status. + * Fetch the parent post to check its status later. + */ if ( $attachment_parent_id ) { $redirect_obj = get_post( $attachment_parent_id ); } + $redirect_url = $attachment_url; }