Make WordPress Core

Opened 6 weeks ago

Last modified 4 weeks ago

#65734 new enhancement

Classic Editor: Support pasted WebP image URLs in TinyMCE smart paste

Reported by: landian Owned by:
Priority: normal Milestone: Future Release
Component: TinyMCE Version: 7.1
Severity: normal Keywords: has-patch needs-testing
Cc: Focuses:

Description

In the Classic Editor, pasting a direct WebP image URL keeps the URL as plain text, while JPG/PNG/GIF URLs are converted into an <img> element by TinyMCE smart paste.

WordPress already supports WebP images, and current TinyMCE documents images_file_types as affecting which image URLs are recognized and placed in an img element by smart_paste. Its default list includes webp.

Steps to reproduce:

  1. Open the Classic Editor visual tab.
  2. Paste a direct image URL ending in .jpg, for example https://example.com/image.jpg.
  3. Confirm it is inserted as an image.
  4. Paste a direct image URL ending in .webp, for example https://example.com/image.webp.

Actual result:
The WebP URL remains plain text.

Expected result:
The WebP URL should be inserted as an image, consistent with JPG/PNG/GIF URL handling.

Patch:
The attached patch minimally updates the bundled TinyMCE paste plugin image URL detection to include webp, without changing file upload, drag-and-drop, or other editor behavior.

Attachments (2)

wp-classic-webp-url-source-only.diff (702 bytes ) - added by landian 6 weeks ago.
classic-webp-url.png (37.1 KB ) - added by sanayasir 6 weeks ago.

Download all attachments as: .zip

Change History (6)

This ticket was mentioned in PR #12718 on WordPress/wordpress-develop by id7368.


6 weeks ago
#1

## Summary
This updates the bundled TinyMCE paste plugin so Classic Editor smart paste recognizes direct WebP image URLs and inserts them as images, matching the existing JPG/PNG/GIF URL behavior.

## Why
WordPress supports WebP images, and current TinyMCE documents images_file_types as affecting which image URLs are recognized and placed in an img element by smart_paste. Its default list includes webp.

## Testing

  • Verified the minimal regex behavior on LC1:
    • .jpg, .jpeg, .png, .gif, .webp, and .WEBP image URLs are recognized.
    • .svg, query-string URLs, and non-absolute URLs keep the previous behavior.
  • Ran JavaScript syntax checks for the modified TinyMCE paste plugin files on LC1.

#2 follow-up: @sanayasir
6 weeks ago

Test Report

I tested this issue in the Classic Editor (Visual mode) and was able to reproduce the reported behavior.

Before Patch

Pasting a direct .jpg, .png, or .gif image URL is automatically converted into an <img> element by TinyMCE Smart Paste.
Pasting a direct .webp image URL leaves the URL as plain text instead of inserting it as an image.

After Patch

Pasting a direct .webp image URL is now correctly converted into an <img> element, matching the existing behavior for .jpg, .png, and .gif image URLs.
I did not observe any regressions in Smart Paste behavior for the existing supported image formats.

Result
The patch resolves the issue by extending TinyMCE Smart Paste image URL detection to include .webp URLs while preserving the existing functionality for other image formats.

Environment:

WordPress: Current development version
Editor: Classic Editor (Visual mode)
Browser: Google Chrome
OS: Windows 10

Patch Testing: ✅ Passed

#3 in reply to: ↑ 2 @landian
5 weeks ago

Thank you for testing.

Replying to sanayasir:

Test Report

I tested this issue in the Classic Editor (Visual mode) and was able to reproduce the reported behavior.

Before Patch

Pasting a direct .jpg, .png, or .gif image URL is automatically converted into an <img> element by TinyMCE Smart Paste.
Pasting a direct .webp image URL leaves the URL as plain text instead of inserting it as an image.

After Patch

Pasting a direct .webp image URL is now correctly converted into an <img> element, matching the existing behavior for .jpg, .png, and .gif image URLs.
I did not observe any regressions in Smart Paste behavior for the existing supported image formats.

Result
The patch resolves the issue by extending TinyMCE Smart Paste image URL detection to include .webp URLs while preserving the existing functionality for other image formats.

Environment:

WordPress: Current development version
Editor: Classic Editor (Visual mode)
Browser: Google Chrome
OS: Windows 10

Patch Testing: ✅ Passed

#4 @wildworks
4 weeks ago

  • Milestone Awaiting ReviewFuture Release
  • Type defect (bug)enhancement
Note: See TracTickets for help on using tickets.