Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#65161 new defect (bug)

Give an error message when a non-image is uploaded for site icon

Reported by: Presskopp Owned by:
Priority: normal Milestone: Awaiting Review
Component: Media Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Just like #39625, when you are on General Settings to Choose a Site Icon, then choose Upload files and select a non-image file, you'll get to a ugly looking page showing a non helping error message. See attached video.

Attachments (1)

non-image.mp4​ (449.8 KB ) - added by Presskopp 5 months ago.

Download all attachments as: .zip

Change History (6)

@Presskopp
5 months ago

#1 @sabernhardt
5 months ago

If someone uploads a text file (or other non-image) for a site icon and selects it, then the 'Crop image' dialog shows the <img> alternative text:

Image crop area preview. Requires mouse interaction.

The button text remains the same as it was in the Upload part of the dialog, and clicking the button has no effect.

  • "Select" in the Customizer
  • "Set as Site Icon" in General Settings

Interestingly, if I resize the window height while the dialog is on the 'Crop image' step, the button text switches to "Crop image" and clicking that triggers an error message.

<div class="upload-error">
	<span class="upload-error-filename word-wrap-break-word">sample.txt</span>
	<span class="upload-error-message">There has been an error cropping your image.</span>
</div>
Last edited 5 months ago by sabernhardt (previous) (diff)

#2 @intenzi
5 months ago

I was able to identify that this issue extends to "Customizer -> Site Identity -> Select Logo" selection and "Customizer -> Header Media -> Add Header Image" selection as well apart from Select Site Icon in General Settings, Customizer.

I am working on a fix for the same.

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

This ticket was mentioned in ​PR #11713 on ​WordPress/wordpress-develop by ​@intenzi.


5 months ago
#3

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/65161

## PR Description

  • Added window alert popup for the Site Icon, Logo and Header Image selections.

Output Video:

## Use of AI Tools
AI assistance: Yes

Tool: Antigravity
Model(s): Gemini 3.5 Pro, Gemini 3 Flash
Used for: Pinpointing the relevant files in the codebase for adding the fix. Final implementation was reviewed by me.

#4 @Presskopp
5 months ago

Nice approach, but I assume you should avoid using window.alert().

#5 @intenzi
5 months ago

Thankyou, I went with window.alert() as the media selection modal overlays on top and thus existing notification systems like the wp.Customize.notification one would get hidden if utilised. This appears to be the correct way to display the error message to the user. Always open to any suggestions if you know of a way it can be improved!

Note: See TracTickets for help on using tickets.