Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Core\Render\RenderContext;
use Drupal\Core\Render\RendererInterface;
use Drupal\file\FileInterface;
use Drupal\file_entity\FileEntityInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
use Drupal\image\Entity\ImageStyle;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -100,6 +101,15 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable

$width = $entity->width;
$height = $entity->height;
// Optionally support the extra data from file_entity.
if ($entity instanceof FileEntityInterface) {
if (empty($width)) {
$width = $entity->getMetadata('width');
}
if (empty($height)) {
$height = $entity->getMetadata('height');
}
}

// @todo Not sure why PHPStan complains here, this should be refactored to
// check the entity properties first.
Expand Down