You are here

function soembed_filter_embed_process in Simple oEmbed 7

Implements hook_filter_FILTER_process().

1 string reference to 'soembed_filter_embed_process'
soembed_filter_info in ./soembed.module
Implements hook_filter_info().

File

./soembed.module, line 29
Lets author embed rich media by inserting URL using oEmbed techonology.

Code

function soembed_filter_embed_process($text, $filter, $format, $langcode, $cache, $cache_id) {
  static $check_settings;

  // Set maxwidth variable for use by soembed_filter_embed(), otherwise cannot pass the value.
  if (empty($check_settings)) {
    if ($filter->settings['soembed_maxwidth'] != variable_get('soembed_maxwidth', 0)) {
      variable_set('soembed_maxwidth', (int) $filter->settings['soembed_maxwidth']);
    }
    $check_settings = TRUE;
  }
  $lines = explode("\n", $text);
  if (!empty($filter->settings['soembed_replace_inline'])) {

    // Match in-line urls. (First () in pattern is needed because the callback
    // expects the url in the second pair of parentheses).
    $lines = preg_replace_callback('#()(https?://[^\\s<]+)#', 'soembed_filter_embed', $lines);
  }
  else {
    $lines = preg_replace_callback('#^(<p>)?(https?://\\S+?)(</p>)?$#', 'soembed_filter_embed', $lines);
  }
  return implode("\n", $lines);
}