function animated_gif_preprocess_image_style in Animated GIF 8
Implements template_preprocess_image_style().
File
- ./
animated_gif.module, line 46
Code
function animated_gif_preprocess_image_style(&$variables) {
// File entity ID is not available here so we need to load it by URI.
$files = \Drupal::entityTypeManager()
->getStorage('file')
->loadByProperties([
'uri' => $variables['uri'],
]);
if (empty($files)) {
return;
}
/** @var \Drupal\file\FileInterface $file */
$file = reset($files);
if ($file
->getMimeType() === 'image/gif' && _animated_gif_is_animated($file
->getFileUri())) {
$variables['image']['#uri'] = $variables['uri'];
unset($variables['image']['#style_name']);
unset($variables['image_style']);
unset($variables['style_name']);
}
}