Display remote inline images in org-mode with automatic caching.
This package displays remote images inline in org-mode with automatic caching. The next time you visit the file or fetch the image, it will be instantly fetched from the cache.
This feature is present in Doom Emacs, and when I switched to GNU emacs, I found that I was quite fond of that feature, so I made it here. You can finally do [[https://gaodean.me/gen/cat.jpg]]
, and have it display inline just like local images. The code here is adapted from the Doom Emacs codebase, and I just thought to make a small plugin to make it simpler to use for GNU emacs users.
(this image would display in emacs with the plugin enabled)
(use-package org-remoteimg
:straight (org-remoteimg :type git :host github :repo "gaoDean/org-remoteimg"))
(add-to-list 'load-path "/path/to/plugin/")
(require 'org-remoteimg)
After the install, remember to do:
;; optional: set this to wherever you want the cache to be stored
;; (setq url-cache-directory "~/.cache/emacs/url")
(setq org-display-remote-inline-images 'cache) ;; enable caching
;; or this if you don't want caching
;; (setq org-display-remote-inline-images 'download)
;; or this if you want to disable this plugin
;; (setq org-display-remote-inline-images 'skip)
By default, this plugin will only cache images. If you want to cache any web request, just do:
;; this is a emacs built-in feature
(setq url-automatic-caching t)
- This plugin works quite well with org-imgtog. Remember to setup caching if you want to use it though, otherwise you’ll have a bad time.
- Credit to Tobias Zawada and his org-yt plugin for the org-mode image display functions.
- Credit to the Doom Emacs community for the basis of the remote image fetching function.