diff options
author | marty hiatt <martianhiatus@riseup.net> | 2024-03-05 10:27:00 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2024-03-05 10:27:00 +0100 |
commit | 814b707198d1451bd016a51fbebcd8b32e6d44bb (patch) | |
tree | a962953dbb107313c7fd16ef7c7ea3f2ac611f07 /lisp/mastodon-media.el | |
parent | 94f310c78dd6204176425f3805ec8b67d30c9c92 (diff) |
RET/click image to view full-sized version in emacs.
Diffstat (limited to 'lisp/mastodon-media.el')
-rw-r--r-- | lisp/mastodon-media.el | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 9dd22f4..9014add 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -177,6 +177,40 @@ with the image." (set-marker marker nil))) (kill-buffer url-buffer)))))) +(defun mastodon-media--process-full-sized-image-response + (status-plist image-options url) + ;; FIXME: refactor this with but not into + ;; `mastodon-media--process-image-response'. + "Callback function processing the `url-retrieve' response for URL. +URL is a full-sized image URL attached to a timeline image. +STATUS-PLIST is a plist of status events as per `url-retrieve'. +IMAGE-OPTIONS are the precomputed options to apply to the image." + (let ((url-buffer (current-buffer)) + (is-error-response-p (eq :error (car status-plist)))) + (let* ((data (unless is-error-response-p + (goto-char (point-min)) + (search-forward "\n\n") + (buffer-substring (point) (point-max)))) + (image (when data + (apply #'create-image data + (if (version< emacs-version "27.1") + (when image-options 'imagemagick) + nil) ; inbuilt scaling in 27.1 + t nil)))) + (when mastodon-media--enable-image-caching + (unless (url-is-cached url) ;; cache if not already cached + (url-store-in-cache url-buffer))) + (with-current-buffer (get-buffer-create "*masto-image*") + (let ((inhibit-read-only t)) + (erase-buffer) + (insert " ") + (when image + (put-text-property (point-min) (point-max) + 'display image) + (image-mode) + (goto-char (point-min)) + (switch-to-buffer-other-window (current-buffer)))))))) + (defun mastodon-media--load-image-from-url (url media-type start region-length) "Take a URL and MEDIA-TYPE and load the image asynchronously. MEDIA-TYPE is a symbol and either `avatar' or `media-link'. |