You are here

function amp_theme_suggestions_image_alter in Accelerated Mobile Pages (AMP) 8.3

Implements hook_theme_suggestions_HOOK_alter().

Add amp-image template suggestion, but only for images that have the AMP layout attribute. This will output these images as <amp-image></amp-image>. We want to control this from the module so the components will work on non-AMP pages, not just AMP pages using AMP theme. The logical name would be amp_image but that name has been used by the image formatter and is in production, it's too hard to replace it with a different implementation.

File

./amp.module, line 307
Provides functionality for handling AMP.

Code

function amp_theme_suggestions_image_alter(array &$suggestions, array $variables) {
  if (!empty($variables['attributes']['layout'])) {
    $suggestions[] = 'amp_image_wrapper';
  }
}