diff --git a/libraries.module b/libraries.module
index 0b45cd9..9a7a5e9 100644
--- a/libraries.module
+++ b/libraries.module
@@ -843,8 +843,9 @@ function _libraries_require_once($file_path) {
  *     account. Defaults to 200. In case of minified or compressed files, this
  *     prevents reading the entire file into memory.
  *
- * @return
- *   A string containing the version of the library.
+ * @return string|null
+ *   A string containing the version of the library or NULL if no version was
+ *   found.
  *
  * @see libraries_get_path()
  */
@@ -872,6 +873,45 @@ function libraries_get_version($library, $options) {
   fclose($file);
 }
 
+function libraries_get_version_from_versions($library) {
+  $version = NULL;
+
+  ksort($library['versions']);
+  foreach ($library['versions'] as $version_properties) {
+    // We support both a single parameter, which is an associative array, and an
+    // indexed array of multiple parameters.
+    if (isset($version_properties['version arguments'][0])) {
+      // Add the library as the first argument.
+      $version = call_user_func_array($version_properties['version callback'], array_merge(array($version_properties), $version_properties['version arguments']));
+    }
+    else {
+      $version = call_user_func($version_properties['version callback'], $version_properties, $version_properties['version arguments']);
+    }
+
+  }
+
+  return $version;
+}
+
+function libraries_get_version_from_variants($library) {
+  $version = NULL;
+
+  foreach ($library['variants'] as $version_properties) {
+    // We support both a single parameter, which is an associative array, and an
+    // indexed array of multiple parameters.
+    if (isset($version_properties['version arguments'][0])) {
+      // Add the library as the first argument.
+      $version = call_user_func_array($version_properties['version callback'], array_merge(array($version_properties), $version_properties['version arguments']));
+    }
+    else {
+      $version = call_user_func($version_properties['version callback'], $version_properties, $version_properties['version arguments']);
+    }
+
+  }
+
+  return $version;
+}
+
 /**
  * Implements hook_help().
  */
