diff --git a/src/wp-admin/includes/class-wp-media-list-table.php b/src/wp-admin/includes/class-wp-media-list-table.php
index fec8d717a2..1943a5966f 100644
--- a/src/wp-admin/includes/class-wp-media-list-table.php
+++ b/src/wp-admin/includes/class-wp-media-list-table.php
@@ -768,13 +768,15 @@ class WP_Media_List_Table extends WP_List_Table {
}
}
- $actions['view'] = sprintf(
- '%s',
- get_permalink( $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
- __( 'View' )
- );
+ if ( get_permalink( $post->ID ) ) {
+ $actions['view'] = sprintf(
+ '%s',
+ get_permalink( $post->ID ),
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
+ __( 'View' )
+ );
+ }
if ( current_user_can( 'edit_post', $post->ID ) ) {
$actions['attach'] = sprintf(
@@ -829,13 +831,15 @@ class WP_Media_List_Table extends WP_List_Table {
}
if ( ! $this->is_trash ) {
- $actions['view'] = sprintf(
- '%s',
- get_permalink( $post->ID ),
- /* translators: %s: Attachment title. */
- esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
- __( 'View' )
- );
+ if ( get_permalink( $post->ID ) ) {
+ $actions['view'] = sprintf(
+ '%s',
+ get_permalink( $post->ID ),
+ /* translators: %s: Attachment title. */
+ esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
+ __( 'View' )
+ );
+ }
$actions['copy'] = sprintf(
'%s',