diff --git a/picture.module b/picture.module
index 4851b7c..8e66136 100644
--- a/picture.module
+++ b/picture.module
@@ -431,7 +431,7 @@ function picture_field_formatter_settings_form($field, $instance, $view_mode, $f
     '#options' => $link_types,
   );
 
-  /* Settings for the colorbox option*/
+  // Settings for the colorbox option.
   $element['colorbox_settings'] = array(
     '#type' => 'fieldset',
     '#tree' => TRUE,
@@ -489,7 +489,7 @@ function picture_field_formatter_settings_form($field, $instance, $view_mode, $f
   );
 
   $caption = array(
-    'auto' =>  t('Automatic'),
+    'auto' => t('Automatic'),
     'title' => t('Title text'),
     'alt' => t('Alt text'),
     'node_title' => t('Content title'),
@@ -602,7 +602,7 @@ function picture_field_formatter_settings_summary($field, $instance, $view_mode)
     $summary[] = filter_xss_admin($link_types[$settings['image_link']]);
   }
 
-  // Dsplay the settings for the colorbox if chosen
+  // Display the settings for the colorbox if chosen.
   if ($settings['image_link'] == 'colorbox') {
     $summary[] = t('Colorbox Group: @setting', array('@setting' => $settings['colorbox_settings']['colorbox_group']));
     $gallery = array(
@@ -618,7 +618,7 @@ function picture_field_formatter_settings_summary($field, $instance, $view_mode)
       $summary[] = '&#8594; ' . t('Colorbox Gallery Custom: @setting', array('@setting' => $settings['colorbox_settings']['colorbox_gallery_custom']));
     }
     $caption = array(
-      'auto' =>  t('Automatic'),
+      'auto' => t('Automatic'),
       'title' => t('Title text'),
       'alt' => t('Alt text'),
       'node_title' => t('Content title'),
@@ -729,9 +729,20 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
 
       $colorbox_settings = $display['settings']['colorbox_settings'];
 
-      // Add the group ID
+      // Add the group ID.
       list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
       $entity_id = !empty($id) ? $entity_type . '-' . $id : 'entity-id';
+      // If this is a file entity field check for the referencing entity to do
+      // the proper grouping.
+      if (isset($entity->referencing_entity) && isset($entity->referencing_field)) {
+        // Because we don't have the entity type we use some "magic" to get a
+        // unique entity identifier.
+        $entity_id = spl_object_hash($entity->referencing_entity);
+        $colorbox_group_field = $entity->referencing_field;
+      }
+      else {
+        $colorbox_group_field = $field['field_name'];
+      }
       switch ($colorbox_settings['colorbox_gallery']) {
         case 'post':
           $gallery_id = 'gallery-' . $entity_id;
@@ -740,10 +751,10 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
           $gallery_id = 'gallery-all';
           break;
         case 'field_post':
-          $gallery_id = 'gallery-' . $entity_id . '-' . $field['field_name'];
+          $gallery_id = 'gallery-' . $entity_id . '-' . $colorbox_group_field;
           break;
         case 'field_page':
-          $gallery_id = 'gallery-' . $field['field_name'];
+          $gallery_id = 'gallery-' . $colorbox_group_field;
           break;
         case 'custom':
           $gallery_id = $colorbox_settings['colorbox_gallery_custom'];
@@ -753,7 +764,7 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
       }
       $element[$delta]['#colorbox_group_id'] = $gallery_id;
 
-      // Add the caption
+      // Add the caption.
       $entity_title = entity_label($entity_type, $entity);
 
       switch ($colorbox_settings['colorbox_caption']) {
@@ -788,10 +799,11 @@ function picture_field_formatter_view($entity_type, $entity, $field, $instance,
           $caption = '';
       }
 
-      // Shorten the caption for the example styles or when caption shortening is active.
+      // Shorten the caption for the example styles or when caption shortening
+      // is active.
       $colorbox_style = variable_get('colorbox_style', 'default');
       $trim_length = variable_get('colorbox_caption_trim_length', 75);
-      if ((variable_get('colorbox_caption_trim', 0)) && (drupal_strlen($caption) > $trim_length)) {
+      if (((strpos($colorbox_style, 'colorbox/example') !== FALSE) || variable_get('colorbox_caption_trim', 0)) && (drupal_strlen($caption) > $trim_length)) {
         $caption = drupal_substr($caption, 0, $trim_length - 5) . '...';
       }
 
