diff --git a/includes/media.filter.inc b/includes/media.filter.inc
index 1a28dc1..8736ddb 100644
--- a/includes/media.filter.inc
+++ b/includes/media.filter.inc
@@ -84,6 +84,11 @@ function media_token_to_markup($match, $wysiwyg = FALSE) {
     if (!isset($tag_info['fid'])) {
       throw new Exception('No file Id');
     }
+
+    // The class attributes is a string, but drupal requires it to be
+    // an array, so we fix it here.
+    $tag_info['attributes']['class'] = explode(" ", $tag_info['attributes']['class']);
+
     if (!isset($tag_info['view_mode'])) {
       // Should we log or throw an exception here instead?
       // Do we need to validate the view mode for fields API?
