Description
Extracting width/height from the physical image is can be extremely expensive, for example when using a distributed file system.
The code supports ->width/->height properties, but these don't actually exist, it seems they are just used for the test?
What does exist is ->width/->height on a certain image field, so if an image derivative is fetched through that, it could possibly set those or something else when passing the entity along for this. I'm not quite sure how you'd define that though, this is the definition that we have for that:
$registry->addFieldResolver('Image', 'derivative',
$builder->compose(
$builder->produce('property_path')
->map('type', $builder->fromValue('field_item:image'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('entity')),
$builder->produce('image_derivative')
->map('entity', $builder->fromParent())
->map('style', $builder->compose(
$builder->fromArgument('style'),
$builder->callback([get_class($this), 'mapImageStyleEnum'])
))
)
);
I assume you would need to intercept the entity somehow and set those properties?
Additionally, what's possible is to optionally support the file_entity module for sites that still use it, which is the case for us, that has metadata on the file entity level and and an API to fetch that. That won't be helpful for many sites out there though. That really should be in core, but that's a different topic.