You are here

function _opigno_video_process in Opigno Video App 7

Opigno video text filter process.

1 string reference to '_opigno_video_process'
opigno_video_app_filter_info in ./opigno_video_app.module
Implements hook_filter_info().

File

./opigno_video_app.module, line 404
Module hooks.

Code

function _opigno_video_process($text, $filter, $format, $langcode, $cache, $cache_id) {

  // Check for shortcodes.
  if (preg_match_all('/\\[opigno-video(\\:(.+))?( .+)?\\]/isU', $text, $matches_code)) {
    foreach ($matches_code[0] as $ci => $code) {

      // Get shortcode attributes.
      $attributes = array(
        'frameborder' => 0,
        'allowfullscreen' => 'allowfullscreen',
        'scrolling' => 'no',
      );
      if (preg_match_all('/(\\w+)=[\'"]([^\'"]+)[\'"]/s', $code, $atrributes_matches)) {
        foreach ($atrributes_matches[1] as $delta => $attribute) {
          $attributes[$attribute] = $atrributes_matches[2][$delta];
        }
      }

      // Build shortcode attributes string.
      $iframe_attributes = drupal_attributes($attributes);

      // Build iframe markup.
      $replacement = '<div class="opigno-video"><iframe ' . $iframe_attributes . '></iframe></div>';

      // Replace shortcode with new markup.
      $text = str_replace($code, $replacement, $text);
    }
  }
  return $text;
}