Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown preview image rendering #21082

Merged
merged 34 commits into from
Nov 22, 2024
Merged

Conversation

mikayla-maki
Copy link
Contributor

@mikayla-maki mikayla-maki commented Nov 22, 2024

Closes #13246

Supersedes: #16192

I couldn't push to the git fork this user was using, so here's the exact same PR but with some style nits implemented.

Release Notes:

  • Added image rendering to the Markdown preview

@notpeter notpeter added the cla-signed The user has signed the Contributor License Agreement label Nov 22, 2024
@mikayla-maki mikayla-maki merged commit 96854c6 into main Nov 22, 2024
12 checks passed
@mikayla-maki mikayla-maki deleted the markdown-preview-image-rendering branch November 22, 2024 22:49
@FireFingers21
Copy link

This is awesome! Just tried it out in the 0.164.2 stable release. The only issue I can see is that the images don't scale. For example, I have a really wide image that I can only see half of in the preview. Resizing the window makes it worse as text wraps correctly, but the image just gets cropped.

@fasterthanlime
Copy link

Happy to see this land — are the supported image types documented anywhere? I use JPEG-XL when authoring Markdown, which is otherwise supported by macOS, Safari, etc. — would be super neat if it ended up being supported in Zed too!

@uncenter
Copy link
Contributor

uncenter commented Dec 5, 2024

Happy to see this land — are the supported image types documented anywhere? I use JPEG-XL when authoring Markdown, which is otherwise supported by macOS, Safari, etc. — would be super neat if it ended up being supported in Zed too!

Seeing as it uses gpui::ImageSource, I think this is the list (of extensions) that it supports:

impl Img {
/// A list of all format extensions currently supported by this img element
pub fn extensions() -> &'static [&'static str] {
// This is the list in [image::ImageFormat::from_extension] + `svg`
&[
"avif", "jpg", "jpeg", "png", "gif", "webp", "tif", "tiff", "tga", "dds", "bmp", "ico",
"hdr", "exr", "pbm", "pam", "ppm", "pgm", "ff", "farbfeld", "qoi", "svg",
]
}
}

@uncenter
Copy link
Contributor

uncenter commented Dec 5, 2024

And going off of the comment in that snippet referring to image::ImageFormat, see image-rs/image#1765.

bennetbo added a commit that referenced this pull request Dec 6, 2024
…ion (#21630)

Follow up to #21082

Similar to checkboxes, you can now click on the image to navigate to the
source location, cmd-clicking opens the url in the browser.


https://github.com/user-attachments/assets/edaaa580-9d8f-490b-a4b3-d6ffb21f197c


Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support images in Markdown preview
6 participants