You are here

protected function MediaOembedPathSubscriber::modifyUrl in Tome 8

Modifies a URL to replace pager query parameters with paths.

Parameters

string $url: A URL.

Return value

string The modified URL.

2 calls to MediaOembedPathSubscriber::modifyUrl()
MediaOembedPathSubscriber::modifyDestination in modules/tome_static/src/EventSubscriber/MediaOembedPathSubscriber.php
Reacts to a modify destination event.
MediaOembedPathSubscriber::modifyHtml in modules/tome_static/src/EventSubscriber/MediaOembedPathSubscriber.php
Reacts to a modify HTML event.

File

modules/tome_static/src/EventSubscriber/MediaOembedPathSubscriber.php, line 61

Class

MediaOembedPathSubscriber
Converts Media OEmbed query parameters to static paths.

Namespace

Drupal\tome_static\EventSubscriber

Code

protected function modifyUrl($url) {
  $query = parse_url($url, PHP_URL_QUERY);
  if (!empty($query) && preg_match('|.*/media/oembed\\?.*|', $url)) {
    $base_path = preg_replace('/\\?.*/', '', $url);
    $url = "{$base_path}/" . md5(urldecode($query));
  }
  return $url;
}