Add image dimension and file size information (#21675)

Closes https://github.com/zed-industries/zed/issues/21281

@jansol, kindly take a look when you're free.


![image](https://github.com/user-attachments/assets/da9a54fa-6284-4012-a243-7e355a5290d3)

Release Notes:

- Added dimensions and file size information for images.

---------

Co-authored-by: tims <0xtimsb@gmail.com>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
Caleb! 2025-02-07 01:56:34 +01:00 committed by GitHub
parent a1ed1a00b3
commit d6d0d7d3e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 312 additions and 10 deletions

View file

@ -2075,8 +2075,25 @@ impl Project {
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
}
self.image_store.update(cx, |image_store, cx| {
let open_image_task = self.image_store.update(cx, |image_store, cx| {
image_store.open_image(path.into(), cx)
});
let weak_project = cx.entity().downgrade();
cx.spawn(move |_, mut cx| async move {
let image_item = open_image_task.await?;
let project = weak_project
.upgrade()
.ok_or_else(|| anyhow!("Project dropped"))?;
let metadata =
ImageItem::load_image_metadata(image_item.clone(), project, &mut cx).await?;
image_item.update(&mut cx, |image_item, cx| {
image_item.image_metadata = Some(metadata);
cx.emit(ImageItemEvent::MetadataUpdated);
})?;
Ok(image_item)
})
}