Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Block: Show snackbar error notice when HEIC image is added #66368

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

AhmarZaidi
Copy link
Contributor

Fixes part of: #66293

What?

This PR adds a 'snackbar' error notice for HEIC image uploads.

Why?

When an HEIC file is uploaded to a server that does not support HEIC to JPEG conversion, and the browser (such as Chrome or Firefox) does not support displaying HEIC, users see the alt text 'This image has an empty alt attribute; its file name is ...', however if we upload an HEIC image from the Media Library.

How?

Added an error notice of type 'snackbar' on image error after checking if the uploaded image is HEIC type.

Testing Instructions

  1. Open a post or page in the WordPress editor.
  2. Add a core/image block.
  3. Upload an HEIC image file.
  4. Observe the error notice that appears, which should include the filename and a suggestion to convert the image to JPEG.

Testing Instructions for Keyboard

N/A

Screenshots or screencast

Screen.Recording.2024-10-23.at.5.11.51.PM.mov

@AhmarZaidi AhmarZaidi marked this pull request as ready for review October 23, 2024 13:47
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

Copy link

github-actions bot commented Oct 23, 2024

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: AhmarZaidi <ahmarzaidi@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: ironprogrammer <ironprogrammer@git.wordpress.org>

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

@adamsilverstein
Copy link
Member

Instead of adding a warning notice, we should probably prevent users from uploading .heic files if their server doesn't support conversion into a web-safe format like jpeg.

sprintf(
/* translators: %s: file name */
__(
'The image file "%s" is in HEIC format, which is not supported by your browser. Consider converting it to JPEG and re-uploading.'
Copy link
Member

Choose a reason for hiding this comment

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

WordPress automatically does this conversion for uploaded HEICs when the server supports it.

@ironprogrammer
Copy link
Contributor

Thanks for the PR, @AhmarZaidi! Though I agree with Adam's comment that preventing [future] HEIC uploads on an unsupported server would be preferable goal. This snackbar would have been a great addition if part of 6.7. However, by the time this update would ship in Core with 6.8, it's likely that it will be more difficult for users to get into this situation.

#66293 is more about warning users that their existing inserted HEIC image is problematic. The placeholder itself looks wonky and doesn't clarify that most users won't be able to view the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants