WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 5 months ago

#33190 new enhancement

Quicktags img button should have a protocol agnostic default value for src attribute

Reported by: peterhartree Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.2.3
Component: Editor Keywords: close
Focuses: ui, javascript, administration Cc:
PR Number:

Description

Desired behaviour
After clicking quicktag img button, the prompt to "Enter the URL of the image' should have a protocol agnostic default value (i.e. two forward slashes or blank).

Actual behaviour
After clicking quick img button, the prompt to "Enter the URL of the image' has a default value of 'http://'.

Reasoning

  • The current behaviour encourages contributors to specify the http:// protocol in the image src. This leads to trouble for anyone running a WordPress instance served over https://.
  • If we wanted to aggressively push best practice (serve assets over https:// wherever possible), the default value should be 'https://'. Realistically though, I'd expect that to cause lots of trouble for people who don't serve their sites over https://. So, defaulting to the protocol agnostic pattern seems like the clear win here.

Attachments (1)

quicktags.js (19.4 KB) - added by peterhartree 4 years ago.
Suggested update to /wp-includes/js/quicktags.js (line #616)

Download all attachments as: .zip

Change History (3)

@peterhartree
4 years ago

Suggested update to /wp-includes/js/quicktags.js (line #616)

#1 @peterhartree
4 years ago

On further reflection, I think the ideal behaviour here would be to set the default according to the return value of force_ssl_content().

If force_ssl_content() is true, default to https://. If false, default to http://.

Clearly this would require a slightly longer patch, but I'm happy to do the work if the community agrees that this change is desirable.

Last edited 4 years ago by peterhartree (previous) (diff)

#2 @azaozz
4 years ago

  • Keywords close added

Thanks @peterhartree for the enhancement idea and the patch.

The image "popup" in Quicktags is used pretty much only for adding external images. Local (uploaded) images are added with the media modal. On top of that in nearly all cases the user has already copied the img src and only uses that popup to paste it.

In that terms don't think we should be changing the current string there. It serves mostly like a placeholder.

Note: See TracTickets for help on using tickets.