You are here

function ckeditor_swf_getinfo in CKEditor SWF - Enhanced Flash embedding plugin 7

Same name and namespace in other branches
  1. 6.2 ckeditor_swf.module \ckeditor_swf_getinfo()
  2. 6 ckeditor_swf.module \ckeditor_swf_getinfo()
1 string reference to 'ckeditor_swf_getinfo'
ckeditor_swf_menu in ./ckeditor_swf.module
Implementation of hook_menu().

File

./ckeditor_swf.module, line 49
Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

Code

function ckeditor_swf_getinfo() {
  drupal_add_http_header('Content-Type', 'text/javascript; charset=utf-8');
  $output = 'null';
  $url = check_url($_REQUEST['src']);

  // Attempt to retrieve info using GD2.
  $info = @getimagesize($url);
  if ($info) {
    if ($info['mime'] == 'application/x-shockwave-flash') {
      $output = '{"mime":"application/x-shockwave-flash", "width":' . $info[0] . ', "height":' . $info[1] . '}';
    }
  }
  else {

    // Attempt to retrieve info using getID3.
    $info = ckeditor_swf_getid3_analyze($url);
    if (isset($info['mime_type'], $info['fileformat'])) {
      $mime = $info['mime_type'];
      $format = $info['fileformat'];
      $prefix = substr($mime, 0, 6);
      if (isset($info['video']['resolution_x'], $info['video']['resolution_y']) && ($prefix == 'video/' || ($mime = 'video/' . $format))) {
        $output = '{"mime":"' . $mime . '", "width":' . $info['video']['resolution_x'] . ', "height":' . $info['video']['resolution_y'] . '}';
      }
      elseif (isset($info['audio']) && ($prefix == 'audio/' || ($mime = 'audio/' . $format))) {
        $output = '{"mime":"' . $mime . '"}';
      }
    }
  }
  print $output;
  exit;
}