diff --git a/src/js/media/views/attachment-filters.js b/src/js/media/views/attachment-filters.js index 7c4d4ff6dda8d..9f5e9e085dce5 100644 --- a/src/js/media/views/attachment-filters.js +++ b/src/js/media/views/attachment-filters.js @@ -28,12 +28,20 @@ AttachmentFilters = wp.media.View.extend(/** @lends wp.media.view.AttachmentFilt // Build `' ).val( value ).html( filter.text )[0], + el: $( '' ).val( value ).html( filterText )[0], priority: filter.priority || 50 }; }, this ).sortBy('priority').pluck('el').value() ); + // Prepend the selectedelement. + this.$el.prepend( '' ); + this.listenTo( this.model, 'change', this.select ); this.select(); }, diff --git a/src/js/media/views/attachment-filters/all.js b/src/js/media/views/attachment-filters/all.js index 16170180fa982..b1b6b11edc8c0 100644 --- a/src/js/media/views/attachment-filters/all.js +++ b/src/js/media/views/attachment-filters/all.js @@ -21,25 +21,27 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment filters[ key ] = { text: text, props: { - status: null, - type: key, + status: null, + type: key, uploadedTo: null, - orderby: 'date', - order: 'DESC', - author: null - } + orderby: 'date', + order: 'DESC', + author: null, + icon: wp.media.view.settings.mimeIcons[key] || false + }, }; }); filters.all = { text: l10n.allMediaItems, props: { - status: null, - type: null, + status: null, + type: null, uploadedTo: null, - orderby: 'date', - order: 'DESC', - author: null + orderby: 'date', + order: 'DESC', + author: null, + icon: 'format-gallery' }, priority: 10 }; @@ -48,12 +50,13 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment filters.uploaded = { text: l10n.uploadedToThisPost, props: { - status: null, - type: null, + status: null, + type: null, uploadedTo: wp.media.view.settings.post.id, - orderby: 'menuOrder', - order: 'ASC', - author: null + orderby: 'menuOrder', + order: 'ASC', + author: null, + icon: 'upload' }, priority: 20 }; @@ -67,7 +70,8 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment type: null, orderby: 'menuOrder', order: 'ASC', - author: null + author: null, + icon: 'no' }, priority: 50 }; @@ -76,12 +80,13 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment filters.mine = { text: l10n.mine, props: { - status: null, - type: null, - uploadedTo: null, - orderby: 'date', - order: 'DESC', - author: uid + status: null, + type: null, + uploadedTo: null, + orderby: 'date', + order: 'DESC', + author: uid, + icon: 'admin-users' }, priority: 50 }; @@ -98,7 +103,8 @@ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.Attachment type: null, orderby: 'date', order: 'DESC', - author: null + author: null, + icon: 'trash' }, priority: 50 }; diff --git a/src/wp-admin/css/media.css b/src/wp-admin/css/media.css index 08155c862049e..bdd5d8953e3ad 100644 --- a/src/wp-admin/css/media.css +++ b/src/wp-admin/css/media.css @@ -446,6 +446,22 @@ border color while dragging a file over the uploader drop area */ .post-type-attachment .wp-filter select { margin: 0 6px 0 0; + appearance: base-select; +} + +.post-type-attachment .wp-filter select::picker(select) { + appearance: base-select; +} + +.post-type-attachment .wp-filter select selectedcontent, +.media-modal-content .media-frame select.attachment-filters selectedcontent { + display: flex; + align-items: center; + gap: .5ch; +} + +.post-type-attachment .wp-filter select::picker-icon { + display: none; } /* Match the spacing the grid view toolbar gets from 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 feac4753d3e92..a8dcff39435cd 100644 --- a/src/wp-admin/includes/class-wp-media-list-table.php +++ b/src/wp-admin/includes/class-wp-media-list-table.php @@ -153,8 +153,9 @@ protected function get_views() { $filter = empty( $_GET['attachment-filter'] ) ? '' : $_GET['attachment-filter']; $type_links['all'] = sprintf( - '', + '', selected( $filter, true, false ), + ' ', __( 'All media items' ) ); @@ -170,26 +171,31 @@ protected function get_views() { false ); + $dashicon = ! empty( $label[3] ) ? " " : ''; + $type_links[ $mime_type ] = sprintf( - '', + '', esc_attr( $mime_type ), $selected, + $dashicon, $label[0] ); } - $type_links['detached'] = ''; + $type_links['detached'] = ''; $type_links['mine'] = sprintf( - '', + '', selected( 'mine' === $filter, true, false ), + ' ', _x( 'Mine', 'media items' ) ); if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) { $type_links['trash'] = sprintf( - '', + '', selected( 'trash' === $filter, true, false ), + ' ', _x( 'Trash', 'attachment filter' ) ); } @@ -316,6 +322,9 @@ public function views() { ?>