diff --git a/includes/insert.inc b/includes/insert.inc
index 94caed9..77a6762 100644
--- a/includes/insert.inc
+++ b/includes/insert.inc
@@ -13,6 +13,7 @@ function insert_insert_styles() {
$insert_styles['auto'] = array('label' => t('Automatic'), 'weight' => -20);
$insert_styles['link'] = array('label' => t('Link to file'), 'weight' => -11);
$insert_styles['image'] = array('label' => t('Original image'), 'weight' => -10);
+ $insert_styles['audio'] = array('label' => t('Audio tag'), 'weight' => -9);
return $insert_styles;
}
@@ -32,11 +33,17 @@ function insert_insert_content($item, $style, $widget) {
if (in_array(strtolower($info['extension']), array('png', 'jpg', 'jpeg', 'gif'))) {
$style_name = 'image';
}
+ elseif (in_array(strtolower($info['extension']), array('mp3', 'wave'))) {
+ $style_name = 'audio';
+ }
}
if ($style_name == 'image') {
return theme('insert_image', array('item' => $item, 'widget' => $widget));
}
+ elseif ($style_name == 'audio') {
+ return theme('insert_audio', array('item' => $item, 'widget' => $widget));
+ }
else {
return theme('insert_link', array('item' => $item, 'widget' => $widget));
}
@@ -63,3 +70,14 @@ function template_preprocess_insert_link(&$vars) {
$vars['class'] = !empty($vars['widget']['settings']['insert_class']) ? $vars['widget']['settings']['insert_class'] : '';
$vars['name'] = $vars['file']->filename;
}
+
+/**
+ * Preprocess variables for the insert-link.tpl.php file.
+ */
+function template_preprocess_insert_audio(&$vars) {
+ $vars['file'] = file_load($vars['item']['fid']);
+ $vars['url'] = insert_create_url($vars['file']->uri);
+ $vars['class'] = !empty($vars['widget']['settings']['insert_class']) ? $vars['widget']['settings']['insert_class'] : '';
+ $vars['name'] = $vars['file']->filename;
+ $vars['mime'] = $vars['file']->filemime;
+}
diff --git a/insert.module b/insert.module
index 81be3b5..56664e2 100644
--- a/insert.module
+++ b/insert.module
@@ -50,6 +50,11 @@ function insert_theme() {
'template' => 'templates/insert-link',
'file' => 'includes/insert.inc',
),
+ 'insert_audio' => array(
+ 'variables' => array('item' => NULL, 'widget' => NULL),
+ 'template' => 'templates/insert-audio',
+ 'file' => 'includes/insert.inc',
+ ),
// Theme functions in includes/image.inc.
'image_insert_image' => array(
diff --git a/templates/insert-audio.tpl.php b/templates/insert-audio.tpl.php
new file mode 100644
index 0000000..5f99a39
--- /dev/null
+++ b/templates/insert-audio.tpl.php
@@ -0,0 +1,24 @@
+ tag.
+ * - __title__: The Title text, intended for use in the tag.
+ * - __description__: A description of the image, sometimes used as a caption.
+ * - __filename__: The file name.
+ * - __[token]_or_filename__: Any of the above tokens if available, otherwise
+ * use the file's name. i.e. __title_or_filename__.
+ */
+?>
+
\ No newline at end of file