Propagate image resolution errors in layout context (#36692)

This commit modifies layout context to propagate any issues that occur
during image
resolution.

At the moment, when errors occur during image resolution we propagate
None upwards. This
hides any potential issues that may be actionable, for example, we may
want to avoid
trying to load an image that failed to load for whatever reason or has
an invalid url.

This commit instead propagates these errors upwards to consumers where
they may become
actionable. This is part of an investigation into #36679.

Signed-off-by: Astraea Quinn Skoutelli
<astraea.quinn.skoutelli@huawei.com>

Signed-off-by: Astraea Quinn Skoutelli <astraea.quinn.skoutelli@huawei.com>
This commit is contained in:
Astraea Quinn S 2025-04-28 14:32:51 +02:00 committed by GitHub
parent 4d975e947b
commit 56882a3d5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 28 deletions

View file

@ -220,13 +220,13 @@ impl ReplacedContents {
image_url.clone().into(),
UsePlaceholder::No,
) {
Some(ImageOrMetadataAvailable::ImageAvailable { image, .. }) => {
Ok(ImageOrMetadataAvailable::ImageAvailable { image, .. }) => {
(Some(image.clone()), image.width as f32, image.height as f32)
},
Some(ImageOrMetadataAvailable::MetadataAvailable(metadata, _id)) => {
Ok(ImageOrMetadataAvailable::MetadataAvailable(metadata, _id)) => {
(None, metadata.width as f32, metadata.height as f32)
},
None => return None,
Err(_) => return None,
};
return Some(Self {