Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Issue #2712111 by slashrsm, paranojik: Outdated cached version of embedded entity #220

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 5 additions & 6 deletions src/EntityHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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);
Expand Down