From f6e43b0a2fa01a76f3598e1f6d521ae71d3f2dad Mon Sep 17 00:00:00 2001 From: Tadej Basa Date: Sun, 24 Apr 2016 14:24:04 +0200 Subject: [PATCH] Issue #2712111 by slashrsm, paranojik: Outdated cached version of embedded entity is displayed when embed tag is updated. --- README.md | 1 + src/EntityHelperTrait.php | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3bc0ccfb..40a645fb 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 `````` 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
tag (instead of appearing on it) the caption filter produces.) ## Usage diff --git a/src/EntityHelperTrait.php b/src/EntityHelperTrait.php index 908502a6..8303637e 100644 --- a/src/EntityHelperTrait.php +++ b/src/EntityHelperTrait.php @@ -193,7 +193,11 @@ protected function renderEntityEmbed(EntityInterface $entity, array $context = a // Build and render the Entity Embed Display plugin, allowing modules to // alter the result before rendering. - $build = $this->renderEntityEmbedDisplayPlugin( + $build = array( + '#theme_wrappers' => ['container'], + '#attributes' => [], + ); + $build['entity'] = $this->renderEntityEmbedDisplayPlugin( $entity, $context['data-entity-embed-display'], $context['data-entity-embed-settings'], @@ -213,11 +217,6 @@ protected function renderEntityEmbed(EntityInterface $entity, array $context = a $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);