WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 4 months ago

#42775 new enhancement

Support uploading files in HEIF and HEVC formats

Reported by: mattheweppelsheimer Owned by:
Milestone: 5.0 Priority: normal
Severity: minor Version: trunk
Component: Upload Keywords: needs-patch
Focuses: administration Cc:

Description

Mac OS X 10.13 High Sierra introduces support for new native image format HEIF and video format HEVF.

These aren't widely used by anyone yet, and absolutely no browsers support displaying HEIFs at present (per CanIUse.com as of 2017-12-02 https://caniuse.com/#feat=heif) — not even Safari. So this clearly isn't a big priority, but it seems likely these will become ubiquitous in time, and it would be good to at least support uploading these file formats, since they are valid media files.

This was brought to my attention by this line in Ars Technica's review of OSX 10.13:

The Ars WordPress CMS won't even let me upload HEIF files [...]

https://arstechnica.com/gadgets/2017/09/macos-10-13-high-sierra-the-ars-technica-review/

We should probably fix that. :)

Attachments (1)

noHEICallowed.png (10.1 KB) - added by jeffr0 5 months ago.
Error When Trying to Upload a HEIC File to WordPress

Download all attachments as: .zip

Change History (14)

#1 @mattheweppelsheimer
6 months ago

  • Keywords 2nd-opinion needs-patch added
  • Severity changed from normal to trivial

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


6 months ago

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


6 months ago

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


5 months ago

#5 @mikeschroder
5 months ago

  • Milestone changed from Awaiting Review to 5.0

I think it makes sense to whitelist the type while support grows for it to be displayable/workable by readily available tools, while putting off full image support until those tools are common.

WordPress whitelists uploads of various types including TIFF that are not natively displayable. As far as I'm aware, this list usually contains most common file formats that are not considered to be a security risk.

#6 @jeffr0
5 months ago

I first tried to upload a HEIC file through the browser to a wordpress.com site and it didn't work because of file permissions. I then logged into the WordPress for iOS app, adding a new post and uploaded a media file directly from the phone which I assume is a HEIC file and it worked.

It turns out the file is not HEIC but is JPEG. I asked the WordPress for iOS developers if the app converts the image format and it does not.

"Hi Jeff, when we pull the image from the OS, it gives it to us in jpg. So we don’t do any converting ourselves within the app" - Will Kwon

I then tried to upload a media file from within the app to a WordPress.org powered site and it didn't work.

I've attached a screenshot of the error that's seen when trying to upload a HEIC file to WordPress.

Last edited 5 months ago by jeffr0 (previous) (diff)

@jeffr0
5 months ago

Error When Trying to Upload a HEIC File to WordPress

#7 @mattheweppelsheimer
4 months ago

  • Keywords 2nd-opinion removed

@mikeschroder's +1 above satisfies the need for a "2nd-opinion"; removing that tag.

I plan to contribute a patch to add these file formats to the upload whitelist. Not a big priority, so this might linger for a while.

#8 @harveyfloyd
4 months ago

  • Component changed from Media to Upload
  • Severity changed from trivial to critical

I would very much like this feature. I offer products created from the new HEIC format and although a preview would be nice I DON'T need or want the file converted to a JPG. I NEED that extra information contained within the file.

#9 follow-up: @mattheweppelsheimer
4 months ago

  • Severity changed from critical to minor

@harveyfloyd Good news: It is already possible to modify the default list of file types WordPress will allow you to upload. Check out the filters upload_mimes and wp_check_filetype_and_ext. Here's an example of a plugin that uses those and might meet your needs out of the box: WP Extra File Types.

Given those workarounds, and given that this change is not critical for the vast majority of WordPress users at this moment in time, I'm walking back the severity property.

#10 @mattheweppelsheimer
4 months ago

This discussion in Slack is important: https://wordpress.slack.com/messages/C02SX62S6/

Summary of takeaways:

  • The scope of this ticket is only to allow *uploads*, not full image support, since underlying libraries WordPress uses to process and display images (GD and Imagick) don't support HEIF. (Here is an Imagick feature request discussion on Github.)
  • So then, why bother? In media asset management use cases it is still valuable to be able to upload media to store and organize it in your WordPress, even if you aren't displaying it.
  • The mime type whitelist is a bit stale; if we're going to change it, it's worth considering more than just heif. webp is further along than heif. flac is a widely-used lossless audio format that apparently we're also missing. Perhaps there are other formats we should also add.
  • Besides a patch, this will need testing to ensure there aren't generic image/ MIME matching conditions that could inadvertently try to process heif files unsupported by GD/Imagick. (Nothing's ever simple, is it?) @bobfolio in Slack raised this point:

only open question would be if there are any generic image/ MIME matching conditions hidden around that might need to be made more specific, if nothing else to avoid unnecessary overhead of running files through libraries that won't end up supporting them anyway. I know there used to be, but am not sure what remains in 4.9.1

#11 @mattheweppelsheimer
4 months ago

Hmm... Are there any default white listed MIME types that can't be displayed on the front end?

If not, introducing some might make for bad UX. I think it's likely some users will be confused if we allow uploading a file that can't be displayed or used in site content. It might appear "broken".

Perhaps this deserves some kind of UI heads up somewhere. Something like, "Hey, this media file can't be displayed in web browsers. You can upload and download HEIF files, but you can't display them on your site." — Or, perhaps we're already supporting un-displayable file type uploads, and already doing exactly that?

#12 in reply to: ↑ 9 @harveyfloyd
4 months ago

Too bad it doesn't work for heic, heif, heics or heifs files. Not even if you add them at the bottom and get all the mime types right.

Replying to mattheweppelsheimer:

@harveyfloyd Good news: It is already possible to modify the default list of file types WordPress will allow you to upload. Check out the filters upload_mimes and wp_check_filetype_and_ext. Here's an example of a plugin that uses those and might meet your needs out of the box: WP Extra File Types.

Given those workarounds, and given that this change is not critical for the vast majority of WordPress users at this moment in time, I'm walking back the severity property.

#13 @mattheweppelsheimer
4 months ago

@harveyfloyd that's odd, not what I expected, and disappointing. It might be worth opening a support ticket for the plugin author to address that. Meanwhile, using the upload_mimes and wp_check_filetype_and_ext hooks sound like the way to go.

Note: See TracTickets for help on using tickets.