[wp-trac] [WordPress Trac] #57361: WP_REST_Attachments_Controller::get_media_types not returning existing mime types, but the ones allowed for upload

WordPress Trac noreply at wordpress.org
Tue Dec 20 14:04:31 UTC 2022


#57361: WP_REST_Attachments_Controller::get_media_types not returning existing mime
types, but the ones allowed for upload
-------------------------+-----------------------------
 Reporter:  david.binda  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  REST API     |    Version:  4.7
 Severity:  normal       |   Keywords:
  Focuses:  rest-api     |
-------------------------+-----------------------------
 While debugging an [https://github.com/WordPress/gutenberg/issues/46658
 issue in Gutenberg's new media tab], it has been
 [https://github.com/WordPress/gutenberg/pull/46676 pointed out] that the
 REST API does not actually allows to list items which are already in media
 library, but can no longer be uploaded (eg.: the list of allowed mime
 types changed over time).

 That's different from what the wp-admin does, as it lists all items in the
 media library, no matter what their (mime)type is, and whether it can be
 uploaded or not.

 The `WP_REST_Attachments_Controller::get_media_types` method
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/rest-
 api/endpoints/class-wp-rest-attachments-controller.php#L1253 uses the
 `get_allowed_mime_types()` function], which is upload oriented (returns a
 list of mime types which can be uploaded), while the
 [https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes
 /class-wp-media-list-table.php#L137 listing in wp-admin uses a logic based
 on existing mime types in the library].

 Thus I wonder, if the same logic as used in wp-admin should be used in the
 REST API, allowing users and developers to get a listing of all existing
 items in the media library, no matter whether new ones can be uploaded or
 not.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57361>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list