WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 6 months ago

#40803 closed defect (bug) (fixed)

Audio or video files do not show on upload

Reported by: karmatosed Owned by: westonruter
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch commit
Focuses: Cc:

Description (last modified by karmatosed)

I think this is a media library issue, but I discovered it whilst testing the audio widget.

If you drag a file it doesn't appear in the library. Here is a gif to show:

https://cldup.com/Q3U_oJF-GH.gif

It's worth noting for images, this does, here is a gif of that:

https://cldup.com/Y5e5DsLY8b.gif

What would be great would be for the behaviour to be constant.

edit: updated to video also as issue thanks to @desrosj finding that

Attachments (3)

40803.1.diff (905 bytes) - added by timmydcrawford 6 months ago.
40803.2.diff (699 bytes) - added by timmydcrawford 6 months ago.
40803.3.diff (395 bytes) - added by timmydcrawford 6 months ago.
removing whitespace changes

Download all attachments as: .zip

Change History (17)

This ticket was mentioned in Slack in #core-media by karmatosed. View the logs.


6 months ago

This ticket was mentioned in Slack in #core by karmatosed. View the logs.


6 months ago

#3 @desrosj
6 months ago

I am seeing this as well, but it also seeing it happen for videos. Using Chrome v 58.0.3029.110.

Last edited 6 months ago by desrosj (previous) (diff)

#4 follow-up: @timmydcrawford
6 months ago

To confirm, the same issue is happening when interacting with the media modal within the post editor - or is it only happening when using the audio widget?

#5 in reply to: ↑ 4 @desrosj
6 months ago

Replying to timmydcrawford:

To confirm, the same issue is happening when interacting with the media modal within the post editor - or is it only happening when using the audio widget?

I do not see the same behavior when editing a post. After uploading a video, it appears in the media library properly.
https://cloudup.com/crw5R4kBYdj+

#6 @karmatosed
6 months ago

  • Description modified (diff)
  • Summary changed from Audio file doesn't show on upload to Audio or video file doesn't show on upload

#7 @karmatosed
6 months ago

  • Component changed from Media to Widgets

@timmydcrawford only in widgets. Just tested and works for post/pages.

Changing to widgets to confirm.

#8 @desrosj
6 months ago

  • Summary changed from Audio or video file doesn't show on upload to Audio or video files do not show on upload

Also, just to add details from our Slack conversation to the ticket.

When opening the modal initially, all pre-existing files of the correct type show up in the modal. This includes any files uploaded on previous page loads using the media widget. This is also not just a Customizer issue, it happens for me when editing media widgets in the admin as well.

#9 @timmydcrawford
6 months ago

  • Keywords has-patch added

Okay I have tracked down the issue here - it appears that by passing in the list of mimes for a given media type in https://core.trac.wordpress.org/browser/trunk/src/wp-admin/js/widgets/media-widgets.js#L252, the underlying query.args.post_mime_type the media modal uses to query/update the listing uses this same list of extensions.

So in the case of the audio widget, the mime which is passed in when creating the insert state for the media modal is audio/mpeg,audio/ogg,audio/mpeg,audio/wav. If you contrast that against the a media modal in the editor, with the "audio" filter set, the post_mime_type in the query is just audio.

40803.1.diff fixes the issue by only passing in the media widgets mime type, instead of the explicit list of mime types. This logic was originally introduced in https://github.com/xwp/wp-core-media-widgets/pull/173 to handle the filtering of .mov files so they would not show up as selectable in the video widget modal. So with this diff, .mov files do show up, but when selected an error is still shown in the preview.

It does seem to me that there might be a way to fix this in the wp.media logic too - because the initial display of the media modal with the explicit mimes works properly, just the subsequent refresh from observing uploads does not.

/cc @westonruter

@timmydcrawford
6 months ago

removing whitespace changes

#10 @timmydcrawford
6 months ago

Dug a bit further and it looks like if we pass in an array of specific mime types, the query performs as expected. 40803.3.diff shows this approach, and maintains the proper filtering of .mov files. Note you can still drag and drop or upload a .mov file - but the original issue reported here is fixed by this diff.

#11 @westonruter
6 months ago

  • Milestone changed from Awaiting Review to 4.8

Related issue of restricting file types during upload: https://github.com/xwp/wp-core-media-widgets/issues/128

#12 @karmatosed
6 months ago

@timmydcrawford tested and confirm this fixes the reported issue.

#13 @westonruter
6 months ago

  • Keywords commit added
  • Owner set to westonruter
  • Status changed from new to accepted

#14 @westonruter
6 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 40836:

Widgets: Ensure that audio and video files appear in media library browser upon upload.

Props timmydcrawford.
Amends [40640].
See #32417, #39994, #39995.
Fixes #40803.

Note: See TracTickets for help on using tickets.