WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#31602 closed enhancement (invalid)

oEmbed: Instagram URL pattern with username in URL

Reported by: danielbachhuber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Embeds Keywords:
Focuses: Cc:

Description

Instagram also gives users URLs like https://instagram.com/pochoy_29/p/yRN4lxGO18/ where pochoy_29 is the username. It would be nice to support this pattern as well.

Change History (5)

#1 @danielbachhuber
6 years ago

Hm, Instagram doesn't recognize the URL in its oEmbed endpoint:

local ➜  wordpress-develop.dev git:(master) ✗ http "https://api.instagram.com/oembed?maxwidth=660&maxheight=990&url=https%3A%2F%2Finstagram.com%2Fpochoy_29%2Fp%2FyRN4lxGO18%2F&format=json"
HTTP/1.1 400 BAD REQUEST
Cache-Control: private, no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Language: en
Content-Length: 12
Content-Type: text/html; charset=utf-8
Date: Wed, 11 Mar 2015 22:13:59 GMT
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
Server: nginx
Set-Cookie: csrftoken=cfa31c0851fac0f68159abc2b0118ac4; expires=Wed, 09-Mar-2016 22:13:59 GMT; Max-Age=31449600; Path=/
Set-Cookie: mid=VQC-JwAEAAGONdjAY_8MxW9PSBvw; expires=Tue, 06-Mar-2035 22:13:59 GMT; Max-Age=630720000; Path=/
Vary: Cookie, Accept-Language

No URL Match

Do we have a contact there?

#2 @ocean90
6 years ago

  • Milestone changed from 4.2 to Future Release

We're already planning beta 1, definitely not 4.2.

#3 @danielbachhuber
6 years ago

This works as a compatibility shim for me:

wp_oembed_add_provider( '#https?://instagram\.com/[^/]+?/p/.*#i', 'https://api.instagram.com/oembed', true );
add_filter( 'oembed_fetch_url', function( $provider, $url, $args ) {
	if ( false === stripos( $provider, 'api.instagram.com' ) ) {
		return $provider;
	}
	$url = preg_replace( '#https?://instagram\.com/([^/]+?/)p/(.*)#i', 'https://instagram.com/p/$2', $url );
	$provider = add_query_arg( 'url', $url, $provider );
	return $provider;
}, 10, 3 );

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


6 years ago

#5 @wonderboymusic
5 years ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed

this URL pattern no longer works - try any image, add the username like you described, 404

Note: See TracTickets for help on using tickets.