Local Environment: Fix resolve for external hosts - #73
Conversation
There was a problem hiding this comment.
Confirming from testing that the mu-plugin filter works as intended to embed media URIs for domains that are included in the $external_hosts array.
I left a comment regarding some other use cases for alternate YouTube URIs that can be shared that we may want to add to the $external_hosts array.
Also noting for comparison that when creating a new WordPress.com hosted site on the web (i.e., not a localhost site using Studio), there are other additional external hosts that are embeddable out-of-the-box (like Vimeo.com URIs, for example).
Approving as I don't consider either a blocker for this PR, but we could consider expanding the domains included in $external_hosts, too.
| } ); | ||
| add_filter( 'http_request_host_is_external', function( $allow, $host, $url ) { | ||
| $external_hosts = array( | ||
| 'www.youtube.com', |
There was a problem hiding this comment.
Noting that this URI will not embed YouTube URLs that do not include the www, and also the shortened domain youtu.be, which is the default URI given when sharing a YouTube video.
E.g., the following URIs would not be embeddable:
https://youtu.be/OmgooFTQhYQ?feature=sharedhttps://youtube.com/watch?v=FcTLMTyD2DU
There was a problem hiding this comment.
I refactored the function to handle those cases ( Actually in all of the examples you provided the host would end up being www.youtube.com, so it wouldn't be a problem, but we need that change the function after all, as it will easily resolve https://github.com/Automattic/dotcom-forge/issues/6738 )
There was a problem hiding this comment.
but we need that change the function after all, as it will easily resolve https://github.com/Automattic/dotcom-forge/issues/6738
Makes sense - I re-tested, and the refactored changes look good to me. Thanks for updating. 👍
|
Can we find a solution that doesn't involve adding hosts to the allowed list? Related Playground issue: WordPress/wordpress-playground#400 |
I'm trying to find one, and this is why I didn't merge it so far. Wasn't familiar with that ticket, so thanks. As this seems bigger than expected, I propose to merge it ( as it seems something that users will want to do sooner or later ), and tackle this more appropriately in the issue mentioned above ( which should do either way ). Then, we can remove this in that ticket, or create another one to remove this file all the way ( As I think it will resolve redirected hosts as well ). |
|
Sorry for mentioning you @wojtekn , I didn't notice you were afk. I added a "Reviewer can merge" so you can do whatever you want ( I'm afk the next days ). |
|
@wojtekn , after the discussions we had, I updated this PR, to always return true for |
wojtekn
left a comment
There was a problem hiding this comment.
Works as expected, thanks for the fix.
Fixes https://github.com/Automattic/dotcom-forge/issues/6808
Fixes https://github.com/Automattic/dotcom-forge/issues/6738
Proposed Changes
This PR adds an extra
mu-pluginto properly resolve domains for embedded urls.Testing Instructions
Test 1
wp-adminTest 2
wp-adminTools -> Import.Pre-merge Checklist