wiki-tui icon indicating copy to clipboard operation
wiki-tui copied to clipboard

Add image support

Open tippfehlr opened this issue 11 months ago • 7 comments

Display images in terminals that support it.

ratatui-image1 could be a simple solution.

Checklist

  • [x] checked that this feature wasn't requested before in an issue
  • [x] read CONTRIBUTING.md

tippfehlr avatar Dec 11 '24 16:12 tippfehlr

Hey @tippfehlr, thanks for your feature request. Implementing inline image rendering list has been on my todo list for a while now.

I don't think it would be that simple integrating images into the rendering pipeline, but I'll work up a poc.

The feature however would need to be behind a feature-flag or at toggle-able in the config, since not all terminals support inline image rendering.

Builditluc avatar Dec 12 '24 06:12 Builditluc

It would be great if it could autodetect if the current terminal supports images. ratatui-image apparently has autodetection and falls back to colored blocks.

I'd propose to display images by default if the terminal supports an image protocol and hide them otherwise (don't display colored blocks). Turning (blocky) images on or off could then be configured.

tippfehlr avatar Dec 12 '24 14:12 tippfehlr

The feature however would need to be behind a feature-flag ...

Yes, please.

... falls back to colored blocks

No, please

A compile feature-flag would be my preferred choice.

0323pin avatar Dec 12 '24 22:12 0323pin

@0323pin I don’t want blocky images either. A compile-time feature-flag is inconvenient for everyone installing wiki-tui from repos. What do you have against detecting terminal support?

tippfehlr avatar Dec 12 '24 22:12 tippfehlr

I'd propose to display images by default if the terminal supports an image protocol and hide them otherwise (don't display colored blocks). Turning (blocky) images on or off could then be configured.

Ok

I don't like images in the terminal, that's all. Fortunately, I use a terminal that doesn't support image rendering.

0323pin avatar Dec 12 '24 22:12 0323pin

+1 for this. There is some info that is missing, in addition to just images;

See for example the entry for 'rocket':

Image

And in wiki-tui it results in <Unsupported Element 'Figure'>:

Image

and note that the <Figure> includes a caption, which is missing in the text interface.

Image

Rather than showing the image itself, perhaps there's a way to show:

  • the alt text or figure caption
  • a link for the image

and then the image itself could be opened in a new layer, if the terminal supports it

techieshark avatar May 29 '25 11:05 techieshark

Having the image open on a separate layer makes a lot of sense:

  • Graceful degradation for unsupported terminals - either activating the caption/figure placeholder does nothing, or downloads it to /tmp and xdg-opens it, or opens it in a browser
  • I'm going to hazard a guess that adding image display into a separate window/layer is less involved than integrating it into the main text window, which introduces all sort of reflowing and layout challenges.
  • reduced bandwidth consumption and visual clutter, since images can be loaded only when they are viewed

jeslinmx avatar May 29 '25 12:05 jeslinmx