|
5 | 5 | use Drupal\Core\DependencyInjection\DependencySerializationTrait; |
6 | 6 | use Drupal\Core\Image\ImageFactory; |
7 | 7 | use Drupal\Core\Plugin\ContainerFactoryPluginInterface; |
| 8 | +use Drupal\file\Entity\File; |
8 | 9 | use Drupal\graphql\GraphQL\Cache\CacheableValue; |
9 | 10 | use Drupal\graphql\GraphQL\Execution\ResolveContext; |
10 | 11 | use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase; |
@@ -69,18 +70,26 @@ public function __construct(array $configuration, $pluginId, $pluginDefinition, |
69 | 70 | */ |
70 | 71 | protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) { |
71 | 72 | if ($value instanceof ImageItem && $value->entity && $value->entity->access('view') && $style = ImageStyle::load($args['style'])) { |
| 73 | + assert($style instanceof ImageStyle); |
72 | 74 | $file = $value->entity; |
| 75 | + assert($file instanceof File); |
73 | 76 |
|
74 | 77 | // Determine the dimensions of the styled image. |
75 | 78 | $dimensions = [ |
76 | 79 | 'width' => $value->width, |
77 | 80 | 'height' => $value->height, |
78 | 81 | ]; |
79 | 82 |
|
80 | | - $style->transformDimensions($dimensions, $file->getFileUri()); |
| 83 | + if ($style->supportsUri($file->getFileUri())) { |
| 84 | + $style->transformDimensions($dimensions, $file->getFileUri()); |
| 85 | + $url = $style->buildUrl($file->getFileUri()); |
| 86 | + } |
| 87 | + else { |
| 88 | + $url = $file->url(); |
| 89 | + } |
81 | 90 |
|
82 | 91 | yield new CacheableValue([ |
83 | | - 'url' => $style->buildUrl($file->getFileUri()), |
| 92 | + 'url' => $url, |
84 | 93 | 'width' => $dimensions['width'], |
85 | 94 | 'height' => $dimensions['height'], |
86 | 95 | ], [$style]); |
|
0 commit comments