You are here

function hook_background_image_css_template_alter in Background Image 2.x

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

Provides extensions a way to alter the CSS template and variables used.

Parameters

array $variables: An associative array of key/value pairs containing:

  • base_class: (string) The base class used in all CSS selectors.
  • background_image_class: (string) The specific background image selector.
  • fallback_url: (string) The fallback background image URL.
  • media_queries: (array) An associative array of media queries:
    • image_style: (string) The image style used.
    • multiplier: (string) The breakpoint multiplier, if it exists.
    • query: (string) The media query rule.
    • url: (string) The background image URL.

string $template_filename: The path to the *.css.twig template file that will be processed with the above $variables.

\Drupal\background_image\BackgroundImageInterface $background_image: The current Background Image entity being processed.

See also

\Drupal\background_image\Controller\BackgroundImageCssController::buildCss

1 invocation of hook_background_image_css_template_alter()
BackgroundImageCssController::buildCss in src/Controller/BackgroundImageCssController.php
Generates the necessary CSS for a background image.

File

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

Code

function hook_background_image_css_template_alter(array &$variables, &$template_filename, \Drupal\background_image\BackgroundImageInterface $background_image) {

  // By default, if a file named "background_image.css.twig" is found in the
  // "templates" directory of an active theme (or the first base theme in its
  // ancestry hierarchy), that template will be used instead of the default
  // module template. If, however, you need/want to place it in a different
  // directory, you will need to explicitly specify it here.
  $template_filename = drupal_get_path('theme', 'my_subtheme') . '/custom_path/background_image.css.twig';
}