Make WordPress Core

Opened 5 years ago

Last modified 5 weeks ago

#48710 accepted defect (bug)

Media uploader does not restrict file upload `accepts` parameters based on current context

Reported by: worddean's profile worddean Owned by: joedolson's profile joedolson
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Media Keywords: needs-patch
Focuses: accessibility Cc:

Description (last modified by joedolson)

Previously titled "PDF uploads are treated like images: empty alt attribute and PHP notices". Changed to reflect the actual issue that needs to be solved in order to fix this.

uploading a .pdf image in posts reads the following;
"this image has an empty alt attribute: its file name is.... .pdf"

I am a regular user since 1.5 versions of WP and this is my first bug, or error report. I tried downgrading, but it kept coming back error.

Change History (57)

#1 @audrasjb
5 years ago

  • Component changed from Posts, Post Types to Media
  • Focuses accessibility added
  • Owner set to audrasjb
  • Severity changed from major to normal
  • Status changed from new to reviewing

Hi @worddean, thank you for opening this ticket and welcome to WordPress Trac!

Self assigning for review.

#2 follow-up: @audrasjb
5 years ago

@worddean could you please clarify which editor you are using when the issue occurs. I can reproduce it in the Block Editor but not sure it's what you are talking about.

For the moment, the block editor is not able to use PDF thumbnails. Worth reporting the issue about the weird message in Gutenberg GitHub repository.

#3 in reply to: ↑ 2 @worddean
5 years ago

Replying to audrasjb:

@worddean could you please clarify which editor you are using when the issue occurs. I can reproduce it in the Block Editor but not sure it's what you are talking about.

For the moment, the block editor is not able to use PDF thumbnails. Worth reporting the issue about the weird message in Gutenberg GitHub repository.

This is an example - http://istartonmonday.com/?p=75520 - as when you post a .pdf it shows and then you click on it to download

#5 @afercia
5 years ago

  • Version 5.3 deleted

Seems to me after a page refresh (or navigating away and re-editing the post) there are also a couple PHP notices related to undefined index $image_meta['file']:

Notice: Undefined index: file in /srv/www/wordpress-develop/public_html/build/wp-includes/media.php 

on line 1535 and 1551. I can reproduce on 5.2 as well (haven't tested previous versions but it's probably there since 5.0?).

To start with, the media views shouldn't allow to select a PDF from the Image block, thus the attachment type should be filtered in the media modal.

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


5 years ago

#7 @afercia
5 years ago

  • Summary changed from 5.3 version - empty alt attribute to PDF uploads are treated like images: empty alt attribute and PHP notices

#8 @afercia
5 years ago

This ticket was discussed during today's accessibility bug-scrub: part of the issue was already reported upstream on the Gutenberg repository. Other parts of this issue relate to the core media instead and should be addressed in core.

Last edited 5 years ago by afercia (previous) (diff)

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


5 years ago

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


5 years ago

#11 @afercia
5 years ago

  • Milestone changed from Awaiting Review to 5.5

This ticket was discussed during today's accessibility bug-scrub: agreed this would be a nice fix for WordPress 5.5.

Reported also on the Gutenberg repo https://github.com/WordPress/gutenberg/issues/18593

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


5 years ago

#13 @afercia
5 years ago

This ticket was discussed during today's accessibility bug-scrub. It would need some prioritisation from the Media team and a Media focus lead yet-to-nominate for the 5.5 milestone.

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


4 years ago

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


4 years ago

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


4 years ago

#17 @davidbaumwald
4 years ago

  • Milestone changed from 5.5 to Future Release

This was discussed during today's scrub. With 5.5 RC1 approaching, this is being moved to Future Release. If any maintainer or committer feels this can be resolved in time, or wishes to assume ownership during a specific cycle, please update the milestone accordingly.

#18 @afercia
4 years ago

  • Keywords needs-patch added
  • Milestone changed from Future Release to 5.6

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


4 years ago

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


4 years ago

#21 @Mista-Flo
4 years ago

  • Keywords reporter-feedback added

Hi there,

I miss some points about this ticket, I need a better understanding.

Could you please provide steps to reproduce the issue @worddean?

Is this only affecting the block editor or also classic editor?

What do we want to fix here, what is the expected result?

EDIT: I better understand the issue when reading the Github issue actually, I'm not sure how to fix the issue though, the media library can be really tricky to modify.

Last edited 4 years ago by Mista-Flo (previous) (diff)

This ticket was mentioned in Slack in #accessibility by audrasjb. View the logs.


4 years ago

#23 @audrasjb
4 years ago

  • Milestone changed from 5.6 to Future Release

As this issue didn't move during 5.6 alpha cycle, let's move it to Future release.

#24 @joedolson
21 months ago

  • Milestone changed from Future Release to 6.3
  • Owner changed from audrasjb to joedolson
  • Status changed from reviewing to accepted

This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.


20 months ago

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


17 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


17 months ago

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


17 months ago

#29 @joedolson
17 months ago

  • Keywords reporter-feedback removed

The root problem here is that the uploader needs to be able to define the accept attribute. When you add an image, the modal only shows images; but you can upload anything, and then you can insert that new item into the image.

When the modal is limited to a class of media, the uploader should also be limited to that class of media.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


17 months ago

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


17 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


17 months ago

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


16 months ago

#34 @chaion07
16 months ago

  • Milestone changed from 6.3 to Future Release

Hello @worddean and thank you for reporting this. We reviewed this ticket during a recent bug-scrub session. We are updating the milestone to Future Release. Thanks!

Props to @mukesh27

#35 @joedolson
16 months ago

  • Milestone changed from Future Release to 6.4

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


16 months ago

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


14 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


14 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


14 months ago

#40 @joedolson
14 months ago

The root cause here is that the uploader isn't getting an accept attribute that matches the current collection filters, so you can upload file types that aren't a match for what you can use in a given context.

The situation where a PDF is treated like an image is only caused because it's possible to do this; if we properly prevent uploads in these inappropriate places, then we don't have this issue.

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


13 months ago

#42 @joedolson
13 months ago

  • Milestone changed from 6.4 to 6.5

Moving to 6.5; this is too complex to get resolved in the remaining time this cycle.

#43 @rajinsharwar
12 months ago

  • Keywords 2nd-opinion added

So on this super OLD ticket, what I found is, this isn't really limited to the Image block. We can also upload PDFs in the Video block when we choose to add the file from the Media Library. https://prnt.sc/VbB6wxt2LxZJ

Again, if we try to do the same by clicking the "Upload" button, then we cannot do that, and get an error in the snack bar saying "Sorry, this file type isn't supported here". https://prnt.sc/RR1E-7TbfLmZ

So, this type of double behavior shouldn't be there as far as I think. It isn't logically/technically correct to add a PDF in an Image block, or a Video block. So, my suggestion is, to show an admin notice error when an unsupported file is being selected for a block from the Media Library popup, and block the file entry. We can show the same error like "Sorry, this file type isn't supported here" in an admin notice here: https://prnt.sc/9M2swXgNoblR when an unsupported file format is selected for the specific block.

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


9 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


9 months ago

#46 @joedolson
9 months ago

  • Milestone changed from 6.5 to 6.6

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


8 months ago

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


5 months ago

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


5 months ago

#50 @joedolson
5 months ago

  • Milestone changed from 6.6 to 6.7

It continues to be complicated to resolve the root issue. Punting to 6.7; but I mean it this time.

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


3 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


3 months ago

#53 @joedolson
3 months ago

  • Description modified (diff)
  • Summary changed from PDF uploads are treated like images: empty alt attribute and PHP notices to Media uploader does not restrict file upload `accepts` parameters based on current context

This ticket was mentioned in Slack in #accessibility by rcreators. View the logs.


2 months ago

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


5 weeks ago

#56 @joedolson
5 weeks ago

  • Milestone changed from 6.7 to 6.8

Bumping, again.

#57 @joedolson
5 weeks ago

  • Keywords 2nd-opinion removed
Note: See TracTickets for help on using tickets.