Skip to content
Snippets Groups Projects
Commit 2d7a2bac authored by johnnydarkko's avatar johnnydarkko Committed by Florent Torregrosa
Browse files

Issue #3398875 by johnnydarkko, mglaman: PHP Error when using mock file data

parent a31f6802
No related branches found
No related tags found
1 merge request!9Resolve #3398875 "Php error when"
......@@ -17,7 +17,12 @@ use Drupal\Core\Form\FormStateInterface;
function animated_gif_preprocess_image_formatter(array &$variables) : void {
$image = $variables['item'];
$imageValues = $image->getValue();
$file = File::load($imageValues['target_id']);
if (isset($imageValues['entity'])) {
$file = $imageValues['entity'];
}
elseif (isset($imageValues['target_id'])) {
$file = File::load($imageValues['target_id']);
}
if ($file && $file->getMimeType() === 'image/gif' && AnimatedGifUtility::isAnAnimatedGif($file->getFileUri())) {
$variables['image']['#theme'] = 'image';
......@@ -32,7 +37,12 @@ function animated_gif_preprocess_image_formatter(array &$variables) : void {
function animated_gif_preprocess_responsive_image_formatter(array &$variables) : void {
$image = $variables['item'];
$imageValues = $image->getValue();
$file = File::load($imageValues['target_id']);
if (isset($imageValues['entity'])) {
$file = $imageValues['entity'];
}
elseif (isset($imageValues['target_id'])) {
$file = File::load($imageValues['target_id']);
}
if ($file && $file->getMimeType() === 'image/gif' && AnimatedGifUtility::isAnAnimatedGif($file->getFileUri())) {
$variables['responsive_image']['#theme'] = 'image';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment