Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#64941 new enhancement

Support TikTok carousel embeds

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

Description

TikTok has image-based carousel embeds now. The URL looks like
https://www.tiktok.com/@itsklarissat/photo/7614533377500138782

When trying to embed this URL it will throw an error
https://i.imgur.com/pKKc1Mu.png

If you replace "photo" with "video" in the URL like:
https://www.tiktok.com/@itsklarissat/video/7614533377500138782

It will embed correctly
https://i.imgur.com/vBdnnXg.png

It looks like the oembed regex is:

'#https?://(www\.)?tiktok\.com/.*/video/.*#i'  => array( 'https://www.tiktok.com/oembed', true ),

A second regex to match the photo URL could be added or it could be updated like

'#https?://(www\.)?tiktok\.com/.*/(?:video|photo)/.*#i'  => array( 'https://www.tiktok.com/oembed', true ),

An alternate solution might be a more generic match, which could account for other URL formats they may add in the future.

'#https?://(www\.)?tiktok\.com/.*/[^/]+/.*#i'  => array( 'https://www.tiktok.com/oembed', true ),

I tested this with WordPress 6.9.4 on Twenty TwentyFive and no plugins.

Change History (5)

This ticket was mentioned in PR #11345 on WordPress/wordpress-develop by NicktheGeek.


5 months ago
#1

  • Keywords has-patch added

Currently, the oembed uses video in the URL, so it does not match photo. This makes it more generic to match video, photo, and other potential future keywords in the URL.

Trac ticket: https://core.trac.wordpress.org/ticket/64941#ticket

## Use of AI Tools

No AI was used to make this code change.

#2 @Nick_theGeek
5 months ago

I added a potential PR that makes for a more generic URL match, so if TikTok adds other keyword options in the URL, it will still match those without requiring future code changes.

#3 @swissspidy
5 months ago

  • Summary TikTok carousel embeds do not workSupport TikTok carousel embeds
  • Type defect (bug)enhancement

#4 @Nick_theGeek
5 months ago

It does look like TikTok might not support requests to the /photo/ URL via the oembed endpoint just yet. I have added a filter to register the endpoint and then modify the provider request URL to swap photo with video in a plugin for now.

#5 @opurockey
5 months ago

'#https?://(www\.)?tiktok\.com/@.*#i' => array( 'https://www.tiktok.com/oembed', true ), 

src/wp-includes/class-wp-oembed.php Line 106

Privider URL is handled here for https://www.tiktok.com/@itsklarissat/photo/7614533377500138782. It seems tiktok doesn't just support /photo for oembed like https://www.tiktok.com/oembed?maxwidth=600&maxheight=750&url=https%3A%2F%2Fwww.tiktok.com%2F%40itsklarissat%2Fphoto%2F7614533377500138782&dnt=1

An alternative could be modify the embed url via using embed_defaults filter.

Note: See TracTickets for help on using tickets.