Skip to content

Ensure HEIC files selectable from “Upload” button - #66292

Merged
getdave merged 5 commits into
WordPress:trunkfrom
adamsilverstein:fix/heic-upload
Nov 4, 2024
Merged

getdave merged 5 commits into
WordPress:trunkfrom
adamsilverstein:fix/heic-upload

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Oct 21, 2024 •

Copy link
Copy Markdown
Member

Fixes #66291.

This may be an upstream Chrome bug, see https://core.trac.wordpress.org/ticket/62268

@github-actions

github-actions Bot commented Oct 21, 2024 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: ironprogrammer <ironprogrammer@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ironprogrammer

Copy link
Copy Markdown
Member

Thank you for the PR, @adamsilverstein!

In my testing, this resolves the issue, and allows HEIC files to be selected for upload on the post screen. ✅

@swissspidy

Copy link
Copy Markdown
Member

For testing, what if the server doesn‘t support HEIC?

@andrewserong andrewserong added [Type] Bug An existing feature does not function as intended [Feature] Media Anything that impacts the experience of managing media [Block] Image Affects the Image Block Backport to WP 6.7 Beta/RC labels Oct 22, 2024
@ndiego

ndiego commented Oct 22, 2024

Copy link
Copy Markdown
Member

For testing, what if the server doesn‘t support HEIC?

Yeah, while this fix addresses the situation where an HEIC image is not selectable, there is still an issue with HEIC images being uploadable when they shouldn't be.

In the video below, I tested in Playground, which does not include ImageMagick. In this situation, I don't think you should be able to upload an HEIC image. Now, it's important to note that this behavior currently exists in 6.6.

So, it's not a regression, but it's still an unfortunate bug that will become more noticeable once 6.7 is out and people start trying to use HEIC images when they are not supported.

heic-bug.mp4

@afercia

afercia commented Oct 22, 2024

Copy link
Copy Markdown
Contributor

Related: #66293

@Mamaduka

Copy link
Copy Markdown
Member

Instead of updating all individual uses, maybe we should enhance the FormFileUpload component when the accept prop contains image/*. I believe all accept props from different components are passed down to it at the end.

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
@adamsilverstein

Copy link
Copy Markdown
Member Author

Instead of updating all individual uses, maybe we should enhance the FormFileUpload component when the accept prop contains image/*. I believe all accept props from different components are passed down to it at the end.

That makes sense and it would be easier to revert if/when Chrome lands the fix in stable as well. I looked at that originally, but since FormFileUpload could be used elsewhere there would need to be added logic to only add the type when uploading images as you said, adding some complexity.

I can rework with that approach.

@adamsilverstein

adamsilverstein commented Oct 22, 2024 •

Copy link
Copy Markdown
Member Author

In the video below, I tested in Playground, which does not include ImageMagick. In this situation, I don't think you should be able to upload an HEIC image. Now, it's important to note that this behavior currently exists in 6.6.

You shouldn't be able to upload HEIC files when the server doesn't support them. This is a completely separate issue from being able to select HEIC images in the file upload button though.

It looks like core media handles this correctly, but not in Gutenberg. This issue should address that: #66293

@Mamaduka

Copy link
Copy Markdown
Member

@adamsilverstein, a bit of naive logic below, but I think it should do the trick.

// @todo: Explain the need for the `image/heic` type and link the Chrome bug.
const compatAccept = !! accept?.includes( 'image/*' )
	? `${ accept }, image/heic`
	: accept;

@swissspidy

Copy link
Copy Markdown
Member

This should probably also add image/heif btw

@adamsilverstein

Copy link
Copy Markdown
Member Author

This should probably also add image/heif btw

We can, although I have yet to locate an image with the mime type image/heif...

@swissspidy

Copy link
Copy Markdown
Member

There was just one added to https://core.trac.wordpress.org/ticket/62272 yesterday

@adamsilverstein

Copy link
Copy Markdown
Member Author

Note: this has been fixed upstream in Chromium; I'm not sure how long that fix takes to make it to the Stable channel.

https://chromium-review.googlesource.com/c/chromium/src/+/5967494

@getdave

getdave commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Testing this now with a view to bring into the packages release for the final RC3 of WP 6.7.

@getdave getdave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and confirmed that this allows selection of HEIC images. The rationale for the fix is good and I think we should bring this into WordPress 6.7.

@getdave
getdave merged commit c5921d7 into WordPress:trunk Nov 4, 2024
@github-actions github-actions Bot added this to the Gutenberg 19.7 milestone Nov 4, 2024
gutenbergplugin pushed a commit that referenced this pull request Nov 4, 2024
* Ensure HEIC files selectable from “Upload” button

* Update packages/components/src/form-file-upload/index.tsx

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>

* move “image/heic” addition to FormFileUpload component

* add image/heif

---------

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: ironprogrammer <ironprogrammer@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
@github-actions

github-actions Bot commented Nov 4, 2024

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 5d0412a

@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Nov 4, 2024
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
* Ensure HEIC files selectable from “Upload” button

* Update packages/components/src/form-file-upload/index.tsx

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>

* move “image/heic” addition to FormFileUpload component

* add image/heif

---------

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: ironprogrammer <ironprogrammer@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
cbravobernal added a commit that referenced this pull request Nov 19, 2024
cbravobernal added a commit that referenced this pull request Nov 20, 2024
…Safari (#67139)

* Revert "Ensure HEIC files selectable from “Upload” button (#66292)"

This reverts commit c5921d7.

* Update changelog

* Make it Safari conditional

* Remove extra whitespaces

* Update changelog

* Use globalthis

* Forgot a #

* Make it safer

Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: azaozz <azaozz@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
cbravobernal added a commit that referenced this pull request Nov 20, 2024
…Safari (#67139)

* Revert "Ensure HEIC files selectable from “Upload” button (#66292)"

This reverts commit c5921d7.

* Update changelog

* Make it Safari conditional

* Remove extra whitespaces

* Update changelog

* Use globalthis

* Forgot a #

* Make it safer

Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: azaozz <azaozz@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Image Affects the Image Block [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Chrome: Unable to upload HEIC image through post editor

8 participants