diff --git a/wp-admin/media.php b/wp-admin/media.php index da087614ce..b280d3ab0a 100644 --- a/wp-admin/media.php +++ b/wp-admin/media.php @@ -14,13 +14,13 @@ case 'editattachment' : if ( empty($errors) ) { $location = 'media.php'; if ( $referer = wp_get_original_referer() ) { - if ( false !== strpos($referer, 'upload.php') ) + if ( false !== strpos($referer, 'upload.php') || ( url_to_postid($referer) == $attachment_id ) ) $location = $referer; } - if ( false !== strpos($referer, 'upload.php') ) { + if ( false !== strpos($location, 'upload.php') ) { $location = remove_query_arg('message', $location); $location = add_query_arg('posted', $attachment_id, $location); - } else { + } elseif ( false !== strpos($location, 'media.php') ) { $location = add_query_arg('message', 'updated', $location); } wp_redirect($location); diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index cb58190689..c984e50962 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -67,7 +67,7 @@ function url_to_postid($url) { $url = apply_filters('url_to_postid', $url); // First, check to see if there is a 'p=N' or 'page_id=N' to match against - if ( preg_match('#[?&](p|page_id)=(\d+)#', $url, $values) ) { + if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) { $id = absint($values[2]); if ($id) return $id;