diff --git a/photoswipe.module b/photoswipe.module
index e32cd4a..976b6b9 100644
--- a/photoswipe.module
+++ b/photoswipe.module
@@ -176,10 +176,14 @@ function photoswipe_field_formatter_settings_summary($field, $instance, $view_mo
  * Implements hook_field_formatter_view().
  */
 function photoswipe_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
-  $element = array(
-    '#type' => 'container',
-    '#attributes' => array('class' => array('photoswipe-gallery')),
-  );
+  $element = array();
+
+  if (!empty($items)) {
+    $element = array(
+      '#type' => 'container',
+      '#attributes' => array('class' => array('photoswipe-gallery')),
+    );
+  }
 
   foreach ($items as $delta => $item) {
     $element[$delta] = array(
     