diff --git a/contrib/search_api_attachments_entityreference/README.txt b/contrib/search_api_attachments_entityreference/README.txt
index 27330a5..24b3873 100644
--- a/contrib/search_api_attachments_entityreference/README.txt
+++ b/contrib/search_api_attachments_entityreference/README.txt
@@ -8,11 +8,13 @@ Example:
 You have a node that has 2 fields :
 
  field_documents: a File field.
- field_references: an Entityreference field, that is containing some file fields:
+ field_references: an Entityreference field, that references a node containing
+ some file fields:
    field_referenced_documents1: a File field.
    field_referenced_documents2: a File field.
+ field_file_reference: an Entityreference field, that references a file entity.
 
 To index the field_documents content, you don't need this submodule, just use
 the search_api_attachments module.
-To index field_referenced_documents1 and field_referenced_documents2 content
-in our node index, you can use this submodule :)
+To index field_referenced_documents1, field_referenced_documents2, and
+field_file_reference content in our node index, you can use this submodule :)
diff --git a/contrib/search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc b/contrib/search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc
index f6ca358..914ccb9 100644
--- a/contrib/search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc
+++ b/contrib/search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc
@@ -27,14 +27,26 @@ class SearchApiAttachmentsEntityreferenceAlterSettings extends SearchApiAttachme
     $file_fields = $this->getFileFields();
 
     foreach ($items as $id => &$item) {
-      $item_wrapper = entity_metadata_wrapper($this->index->item_type, $item);
+      // Support the search_api_et module. It adds its prefix to entity types.
+      $entity_type = (strpos($this->index->item_type, 'search_api_et_') === 0) ? substr($this->index->item_type, 14) : $this->index->item_type;
+      $item_wrapper = entity_metadata_wrapper($entity_type, $item);
 
       // Case of entity reference fields.
       foreach ($entityreference_fields as $entityreference_field) {
         if (isset($item->{$entityreference_field['field_name']})) {
           $referenced_entities = $item_wrapper->{$entityreference_field['field_name']}->value();
+          if (is_object($referenced_entities)) {
+            // The wrapper can return either an array of entity objects, or a
+            // single entity object. We want the result be an array always.
+            $referenced_entities = array($referenced_entities);
+          }
           // Index the files content.
-          if (!empty($file_fields)) {
+          if ($entityreference_field['settings']['target_type'] == 'file') {
+            if ($content = $this->getFilesContent($referenced_entities, $exclude, $max_file_size)) {
+              $item->{'attachments_' . $entityreference_field['field_name']} = $content;
+            }
+          }
+          elseif (!empty($file_fields)) {
             foreach ($file_fields as $file_field) {
               foreach ($referenced_entities as $referenced_entity) {
                 // The referenced entity has the file field.
@@ -42,28 +54,8 @@ class SearchApiAttachmentsEntityreferenceAlterSettings extends SearchApiAttachme
                   // Get the files.
                   $files = field_get_items($entityreference_field['settings']['target_type'], $referenced_entity, $file_field['field_name']);
                   if (!empty($files)) {
-                    // Limit to the max number of value per field.
-                    if (isset($this->options['number_indexed']) && $this->options['number_indexed'] != '0' && count($files) > $this->options['number_indexed']) {
-                      $files = array_slice($files, 0, $this->options['number_indexed']);
-                    }
-                    foreach ($files as $file) {
-                      // Private file restriction.
-                      if (!$this->is_temporary($file) && !($this->options['excluded_private'] && $this->is_private($file))) {
-                        // Extension restriction.
-                        if (!in_array($file['filemime'], $exclude)) {
-                          // File size restriction.
-                          $file_size_errors = file_validate_size((object) $file, $max_file_size);
-                          if (empty($file_size_errors)) {
-                            $attachments = 'attachments_' . $file_field['field_name'];
-                            if (isset($item->{$attachments})) {
-                              $item->{$attachments} .= ' ' . $this->getFileContent($file);
-                            }
-                            else {
-                              $item->{$attachments} = $this->getFileContent($file);
-                            }
-                          }
-                        }
-                      }
+                    if ($content = $this->getFilesContent($files, $exclude, $max_file_size)) {
+                      $item->{'attachments_' . $file_field['field_name']} = $content;
                     }
                   }
                 }
@@ -88,7 +80,7 @@ class SearchApiAttachmentsEntityreferenceAlterSettings extends SearchApiAttachme
       );
     }
     else {
-      $fields = $this->getFileFields();
+      $fields = $this->getFileFields() + $this->getEntityReferenceFields();
       foreach ($fields as $name => $field) {
         $ret['attachments_' . $name] = array(
           'label' => 'Attachment content: ' . $name,
@@ -125,4 +117,41 @@ class SearchApiAttachmentsEntityreferenceAlterSettings extends SearchApiAttachme
     }
     return $ret;
   }
+
+  /**
+   * Extracts and returns contents of files.
+   *
+   * @param array $files
+   *   The array of file objects/arrays.
+   * @param array $exclude
+   *   The array of file extensions to exclude.
+   * @param int $max_file_size
+   *   The maximum file size.
+   *
+   * @return string
+   *   Extracted contents of files imploded by the space character.
+   */
+  protected function getFilesContent($files, $exclude, $max_file_size) {
+    $ret = '';
+    // Limit to the max number of value per field.
+    if (isset($this->options['number_indexed']) && $this->options['number_indexed'] != '0' && count($files) > $this->options['number_indexed']) {
+      $files = array_slice($files, 0, $this->options['number_indexed']);
+    }
+    foreach ($files as $file) {
+      $file = (array) $file;
+      // Private file restriction.
+      if (!$this->is_temporary($file) && !($this->options['excluded_private'] && $this->is_private($file))) {
+        // Extension restriction.
+        if (!in_array($file['filemime'], $exclude)) {
+          // File size restriction.
+          $file_size_errors = file_validate_size((object) $file, $max_file_size);
+          if (empty($file_size_errors)) {
+            $ret .= ' ' . $this->getFileContent($file);
+          }
+        }
+      }
+    }
+    return trim($ret);
+  }
+
 }
