Skip to content

Commit

Permalink
Merge pull request #68 from quantcdn/feature/oembed-media
Browse files Browse the repository at this point in the history
Added support for media oembed iframes.
  • Loading branch information
stooit authored Sep 21, 2022
2 parents e2793c8 + 51f139b commit 52f49ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions modules/quant_api/src/EventSubscriber/QuantApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,16 @@ public function onOutput(QuantEvent $event) {
}
}

// Media oEmbed support.
// Core media may be embedded via iFrame not included by the seed process.
// This content can be detected and included on the fly.
/** @var \DOMElement $node */
foreach ($xpath->query('//iframe[contains(@src, "/media/oembed")]') as $node) {
$oembed_url = $new_href = $node->getAttribute('src');
$oembed_item = new RouteItem(['route' => $oembed_url]);
$oembed_item->send();
}

// @todo Report on forms that need proxying (attachments.forms).
}

Expand Down
7 changes: 5 additions & 2 deletions src/Seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,11 @@ public static function headRoute($route, array $headers = []) {
*/
public static function markupFromRoute($route, array $headers = []) {

// Cleanse route.
$route = str_replace('//', '/', $route);
// Clean double slashes from routes.
// The exception is oEmbed routes which passes a full URL as query param.
if (!preg_match('/\/media\/oembed\?url=/', $route)) {
$route = str_replace('//', '/', $route);
}

// Build internal request.
$config = \Drupal::config('quant.settings');
Expand Down

0 comments on commit 52f49ab

Please sign in to comment.