You are here

function icon_select_preprocess_page in Icon Select 8

Implements hook_preprocess_page().

File

./icon_select.module, line 40
Basic module file for icon_select module.

Code

function icon_select_preprocess_page(&$vars) {
  $svg_path = SvgSpriteGenerator::getSpriteDestinationPath();
  if (file_exists($svg_path)) {

    // Add a random string to disable caching of AJAX request.
    $full_url = file_url_transform_relative(file_create_url(SvgSpriteGenerator::getSpriteDestinationPath()));
    $url = $full_url . '?hash=' . \Drupal::state()
      ->get('icon_select_hash');
    $vars['#attached']['drupalSettings']['icon_select']['icon_select_url'] = $url;
  }
}