You are here

function hook_background_image_text_after_build_alter in Background Image 2.0.x

Same name and namespace in other branches
  1. 8 background_image.api.php \hook_background_image_text_after_build_alter()
  2. 2.x background_image.api.php \hook_background_image_text_after_build_alter()

Provides extensions a way to alter the text after it's been tokenized.

Parameters

array $element: The text render array element.

array $context: An associative array containing:

1 invocation of hook_background_image_text_after_build_alter()
BackgroundImageViewBuilder::buildText in src/BackgroundImageViewBuilder.php
Builds the text render array.

File

./background_image.api.php, line 103
API hooks and alters for the background_image module.

Code

function hook_background_image_text_after_build_alter(array &$element, array &$context) {

  // Remove any empty tags that may exist due to tokens not matching.
  $element['#text'] = preg_replace('/(?:\\n|\\s*)?<([^>\\s]+)[^>]*>(?:(?:<br\\s*\\/?>|&nbsp;|&thinsp;|&ensp;|&emsp;|&#8201;|&#8194;|&#8195;|\\n|\\r|\\s)*)*<\\/\\1>(?:\\n|\\s*)?/mi', '', $element['#text']);
}