Make WordPress Core

Opened 9 years ago

Closed 2 years ago

#31920 closed enhancement (worksforme)

oEmbed: Support YouTube timestamps as hashes

Reported by: danielbachhuber's profile danielbachhuber Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: Priority: normal
Severity: normal Version:
Component: Embeds Keywords: needs-patch needs-unit-tests good-first-bug close
Focuses: Cc:


YouTube can provide timestamps as a hash, which doesn't get properly processed by the oEmbed endpoint:

Converting the hash to a proper query argument produces the expected behavior:

Although it's a pain to maintain compatibility shims, including in core would reduce user confusion around oEmbed.

 * Support YouTube timestamp as hash (e.g.
 * by converting the hash to a query arg
add_filter( 'oembed_fetch_url', function( $provider, $url, $args ) {
	if ( false === stripos( $provider, '' ) || false === stripos( $url, '#t=' ) ) {
		return $provider;
	$url = str_replace( '#t=', '&t=', $url );
	$provider = add_query_arg( 'url', rawurlencode( $url ), $provider );
	return $provider;
}, 10, 3 );

Change History (12)

#1 @Viper007Bond
9 years ago

Agreed. Helpers are annoying, but fixing this issue is worth it.

#2 @swissspidy
9 years ago

Perhaps other providers support this as well. I know that Vimeo supports that hash, but I think not the query param for embeds.

#3 @swissspidy
8 years ago

  • Milestone changed from Future Release to 4.6

#4 @peterwilsoncc
8 years ago

  • Keywords needs-unit-tests added
  • Owner set to peterwilsoncc
  • Status changed from new to accepted

This ticket was mentioned in Slack in #core by ocean90. View the logs.

8 years ago

#6 @peterwilsoncc
8 years ago

Edge cases need to be dealt with, the first to come to mind is campaign tags and a time stamp:

I'll keep on the milestone for now as I'm working through a patch with a (hopefully soon) first contributor.

#7 @peterwilsoncc
8 years ago

  • Milestone changed from 4.6 to Future Release
  • Status changed from accepted to assigned

#8 @desrosj
4 years ago

  • Keywords good-first-bug added
  • Milestone set to Future Release

This would still be a really nice enhancement. Adding good-first-bug as a newer contributor should be able dive in on this one.

#9 @psrpinto
3 years ago

I tested this on version 5.7.2 and the issue appears to have been fixed.

Using both the Classic Editor and the Block Editor, links with the timestamp as either a hash or a query argument, are correctly embedded, and the video is set to the correct timestamp.

Tested with:

#10 @karpstrucking
3 years ago

  • Keywords close added

these are working as expected for me as well, marking as a close candidate

#11 @Rahe
2 years ago


Tested on 6.0 with the same urls and it's working as expected.

#12 @peterwilsoncc
2 years ago

  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from assigned to closed

Thanks for retesting folks.

It looks like YouTube have fixed this with their embed code so I will close the ticket. worksforme seems the closest fit even though it didn't work at the time of the report.

Note: See TracTickets for help on using tickets.