Problem/Motivation
If an iframe domain is set at /admin/config/media/media-settings as recommended, an error is thrown:
nvalidArgumentException: The internal path component 'https://oembed-meric.mo.gov/media/oembed' is invalid. Its path component must have a leading slash, e.g. internal:/foo. in Drupal\Core\Url::fromInternalUri() (line 416 of core/lib/Drupal/Core/Url.php).
Drupal\Core\Url::fromUri('internal:https://oembed-meric.mo.gov/media/oembed?url=https%3A//www.youtube.com/w...') (Line: 120)
media_oembed_control_preprocess_field(Array, 'field', Array)
call_user_func_array('media_oembed_control_preprocess_field', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 48)
__TwigTemplate_ef2502f7e6c19829ebf272c7f8054b0f->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('core/modules/media/templates/media.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('media', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Configure an iframe domain in the media settings. For example, on our sites, we have both "foo.bar" and "oembed-foo.bar" pointing at the site, with "https://oembed-foo.bar" entered as the iframe domain.
Configure the field display settings to include a Media oEmbed Control option.
Attempt to view an oEmbed media item using those settings.
Proposed resolution
I believe this is just a matter of checking the src string before creating a URL from it, and creating it a bit differently if it's not an internal path. However, my first experiment with this got an oembed "doesn't match any known resource" error. I'll try further.
Remaining tasks
User interface changes
API changes
Data model changes