diff --git a/README.md b/README.md
index 3bc0ccf..40a645f 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@ Entity Embed can be installed via the [standard Drupal installation process](htt
   * Enable the 'Display embedded entities' filter.
   * Drag and drop the 'E' button into the Active toolbar.
   * If the text format uses the 'Limit allowed HTML tags and correct faulty HTML' filter, ensure the necessary tags and attributes are whitelisted: add ```<drupal-entity data-entity-type data-entity-uuid data-entity-id data-view-mode data-entity-embed-display data-entity-embed-settings data-align data-caption data-embed-button>``` to the 'Allowed HTML tags' setting. (Will happen automatically after https://www.drupal.org/node/2554687.)
+  * If you're using both the 'Align images' and 'Caption images' filters make sure the 'Align images' filter is run before the 'Caption images' filter in the **Filter processing order** section. (Explanation: Due to the implementation details of the two filters it is important to execute them in the right sequence in order to obtain a sensible final markup. In practice this means that the alignment filter has to be run before the caption filter, otherwise the alignment class will appear inside the <figure> tag (instead of appearing on it) the caption filter produces.)
 
 ## Usage
 
diff --git a/entity_embed.module b/entity_embed.module
index abba0ab..c41c2d5 100644
--- a/entity_embed.module
+++ b/entity_embed.module
@@ -7,6 +7,33 @@
  */
 
 /**
+ * Implements hook_theme().
+ */
+function entity_embed_theme() {
+  return [
+    'entity_embed_container' => [
+      'render element' => 'element',
+    ],
+  ];
+}
+
+/**
+ * Prepares variables for entity embed container templates.
+ *
+ * Default template: entity-embed-container.html.twig.
+ *
+ * @param array $variables
+ *   An associative array containing:
+ *   - element: An associative array containing the properties of the element.
+ *     Properties used: #attributes, #children.
+ */
+function template_preprocess_entity_embed_container(&$variables) {
+  $variables['element'] += ['#attributes' => []];
+  $variables['attributes'] = $variables['element']['#attributes'];
+  $variables['children'] = $variables['element']['#children'];
+}
+
+/**
  * Implements hook_entity_embed_display_plugins_alter() on behalf of file.module.
  */
 function file_entity_embed_display_plugins_alter(array &$plugins) {
diff --git a/src/EntityHelperTrait.php b/src/EntityHelperTrait.php
index 908502a..5692689 100644
--- a/src/EntityHelperTrait.php
+++ b/src/EntityHelperTrait.php
@@ -193,7 +193,13 @@ trait EntityHelperTrait {
 
     // Build and render the Entity Embed Display plugin, allowing modules to
     // alter the result before rendering.
-    $build = $this->renderEntityEmbedDisplayPlugin(
+    $build = array(
+      '#theme_wrappers' => ['entity_embed_container'],
+      '#attributes' => ['class' => ['embedded-entity']],
+      '#entity' => $entity,
+      '#context' => $context,
+    );
+    $build['entity'] = $this->renderEntityEmbedDisplayPlugin(
       $entity,
       $context['data-entity-embed-display'],
       $context['data-entity-embed-settings'],
@@ -213,11 +219,6 @@ trait EntityHelperTrait {
       $build['#attributes']['data-caption'] = $context['data-caption'];
     }
 
-    // If this is an image, the image_formatter template expects #item_attributes.
-    if (!empty($build['#theme']) && !empty($build['#attributes']) && $build['#theme'] == 'image_formatter') {
-      $build['#item_attributes'] =  $build['#attributes'];
-    }
-
     // @todo Should this hook get invoked if $build is an empty array?
     $this->moduleHandler()->alter(array("{$context['data-entity-type']}_embed", 'entity_embed'), $build, $entity, $context);
     $entity_output = $this->renderer()->render($build);
diff --git a/src/Tests/EntityEmbedFilterTest.php b/src/Tests/EntityEmbedFilterTest.php
index 23b4f9a..ce77ea8 100644
--- a/src/Tests/EntityEmbedFilterTest.php
+++ b/src/Tests/EntityEmbedFilterTest.php
@@ -15,6 +15,20 @@ namespace Drupal\entity_embed\Tests;
 class EntityEmbedFilterTest extends EntityEmbedTestBase {
 
   /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'file',
+    'image',
+    'entity_embed',
+    'entity_embed_test',
+    'node',
+    'ckeditor',
+  ];
+
+  /**
    * Tests the entity_embed filter.
    *
    * Ensures that entities are getting rendered when correct data attributes
@@ -32,6 +46,7 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
     $this->assertNoRaw('<drupal-entity data-entity-type="node" data-entity');
     $this->assertText($this->node->body->value, 'Embedded node exists in page');
     $this->assertNoText(strip_tags($content), 'Placeholder does not appear in the output when embed is successful.');
+    $this->assertRaw('<article class="embedded-entity">', 'Embed container found.');
 
     // Tests entity embed using entity UUID and view mode.
     $content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-view-mode="teaser">This placeholder should not be rendered.</drupal-entity>';
@@ -44,6 +59,7 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
     $this->assertNoRaw('<drupal-entity data-entity-type="node" data-entity');
     $this->assertText($this->node->body->value, 'Embedded node exists in page.');
     $this->assertNoText(strip_tags($content), 'Placeholder does not appear in the output when embed is successful.');
+    $this->assertRaw('<article class="embedded-entity">', 'Embed container found.');
 
     // Ensure that placeholder is not replaced when embed is unsuccessful.
     $content = '<drupal-entity data-entity-type="node" data-entity-id="InvalidID" data-view-mode="teaser">This placeholder should be rendered since specified entity does not exists.</drupal-entity>';
@@ -69,6 +85,7 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
     $this->assertText($this->node->body->value, 'Entity specifed with UUID exists in the page.');
     $this->assertNoText($sample_node->body->value, 'Entity specifed with ID does not exists in the page.');
     $this->assertNoText(strip_tags($content), 'Placeholder does not appear in the output when embed is successful.');
+    $this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
 
     // Test deprecated 'default' Entity Embed Display plugin.
     $content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"teaser"}\'>This placeholder should not be rendered.</drupal-entity>';
@@ -80,10 +97,11 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
     $this->drupalGet('node/' . $node->id());
     $this->assertText($this->node->body->value, 'Embedded node exists in page.');
     $this->assertNoText(strip_tags($content), 'Placeholder does not appear in the output when embed is successful.');
+    $this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
 
     // Ensure that Entity Embed Display plugin is preferred over view mode when
     // both attributes are present.
-    $content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"teaser"}\' data-view-mode="some-invalid-view-mode">This placeholder should not be rendered.</drupal-entity>';
+    $content = '<drupal-entity data-entity-type="node" data-entity-uuid="' . $this->node->uuid() . '" data-entity-embed-display="default" data-entity-embed-settings=\'{"view_mode":"full"}\' data-view-mode="some-invalid-view-mode" data-align="left" data-caption="test caption">This placeholder should not be rendered.</drupal-entity>';
     $settings = array();
     $settings['type'] = 'page';
     $settings['title'] = 'Test entity embed with entity-embed-display and data-entity-embed-settings';
@@ -92,6 +110,12 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
     $this->drupalGet('node/' . $node->id());
     $this->assertText($this->node->body->value, 'Embedded node exists in page with the view mode specified by entity-embed-settings.');
     $this->assertNoText(strip_tags($content), 'Placeholder does not appear in the output when embed is successful.');
+    $this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
+
+    // Ensure the embedded node doesn't contain data tags on the full page.
+    $this->drupalGet('node/' . $this->node->id());
+    $this->assertNoRaw('data-align="left"', 'Align data attribute not found.');
+    $this->assertNoRaw('data-caption="test caption"', 'Caption data attribute not found.');
 
     // Test that tag of container element is not replaced when it's not
     // <drupal-entity>.
@@ -113,6 +137,25 @@ class EntityEmbedFilterTest extends EntityEmbedTestBase {
     $this->drupalget('node/' . $node->id());
     $this->assertNoText($this->node->body->value, 'embedded node exists in page');
     $this->assertRaw('<div data-entity-type="node" data-entity-id');
+
+    // Test that attributes are correctly added when image formatter is used.
+    /** @var \Drupal\file\FileInterface $image */
+    $image = $this->getTestFile('image');
+    $image->setPermanent();
+    $image->save();
+    $content = '<drupal-entity data-entity-type="file" data-entity-uuid="' . $image->uuid() . '" data-entity-embed-display="image:image" data-entity-embed-settings=\'{"image_style":"","image_link":""}\' data-align="left" data-caption="test caption" alt="This is alt text" title="This is title text">This placeholder should not be rendered.</drupal-entity>';
+    $settings = [];
+    $settings['type'] = 'page';
+    $settings['title'] = 'test entity image formatter';
+    $settings['body'] = [['value' => $content, 'format' => 'custom_format']];
+    $node = $this->drupalCreateNode($settings);
+    $this->drupalget('node/' . $node->id());
+    $this->assertRaw('<img src', 'IMG tag found.');
+    $this->assertRaw('data-caption="test caption"', 'Caption found.');
+    $this->assertRaw('data-align="left"', 'Alignment information found.');
+    $this->assertTrue((bool) $this->xpath("//img[@alt='This is alt text']"), 'Alt text found');
+    $this->assertTrue((bool) $this->xpath("//img[@title='This is title text']"), 'Title text found');
+    $this->assertRaw('<article class="embedded-entity"', 'Embed container found.');
   }
 
 }
diff --git a/tests/modules/entity_embed_test/entity_embed_test.module b/tests/modules/entity_embed_test/entity_embed_test.module
index d413899..2c64a74 100644
--- a/tests/modules/entity_embed_test/entity_embed_test.module
+++ b/tests/modules/entity_embed_test/entity_embed_test.module
@@ -70,6 +70,5 @@ function entity_embed_test_entity_embed_alter(array &$build, EntityInterface $en
   }
 
   // Set title of the 'node' entity.
-  $node = $build['#node'];
-  $node->setTitle("Title set by hook_entity_embed_alter");
+  $entity->setTitle("Title set by hook_entity_embed_alter");
 }
