Problem when calling jquery_media_add with an option array when jQ is enabled

andirez - August 4, 2009 - 13:01
Project:jQuery Media
Version:6.x-1.4-beta1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

There is a problem when you call the jquery_media_add with the jQ module enabled and when you want to specify a custom option array. Problem here is that the module_invoke function call does not pass the $options parameter.

Here is a tested fix for the function:

<?php
/**
*  Attempt to go through jQ first. Then add our files manually.
*/
function jquery_media_add($options = array()) {
  static
$installed = FALSE;
  if (
module_exists('jq')) {
    return
module_invoke('jq', 'add', 'jquery_media', $options);
  }
  if (!
$installed) {
   
drupal_add_js(drupal_get_path('module', 'jquery_media') .'/js/jquery.media.js');
  }
 
module_load_include('inc', 'jquery_media', 'jquery_media.jq');
 
_jquery_media_add($options);
  return
TRUE;
}
?>

As you will see, I added $options as an additional parameter on the following line:

<?php
return module_invoke('jq', 'add', 'jquery_media', $options);
?>

(jquery_media.module line 61)

 
 

Drupal is a registered trademark of Dries Buytaert.