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.  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:
parent
a1ed1a00b3
commit
d6d0d7d3e4
10 changed files with 312 additions and 10 deletions
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue