From 14842fce7caa96c0f6234308c85a82a8e556f18f Mon Sep 17 00:00:00 2001 From: mousebot Date: Mon, 13 Sep 2021 20:14:28 +0200 Subject: use inbuilt image scaling if emacs version => 27.1 and put point at point-min on profile load --- lisp/mastodon-media.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-media.el') diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 381d994..2100553 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -41,7 +41,7 @@ :prefix "mastodon-media-" :group 'mastodon) -(defcustom mastodon-media--avatar-height 30 +(defcustom mastodon-media--avatar-height 20 "Height of the user avatar images (if shown)." :group 'mastodon-media :type 'integer) @@ -146,7 +146,10 @@ REGION-LENGTH is the length of the region that should be replaced with the image (search-forward "\n\n") (buffer-substring (point) (point-max)))) (image (when data - (apply #'create-image data (when image-options 'imagemagick) + (apply #'create-image data + (if (version< emacs-version "27.1") + (when image-options 'imagemagick) + nil) ; inbuilt scaling in 27.1 t image-options)))) (with-current-buffer (marker-buffer marker) ;; Save narrowing in our buffer @@ -170,7 +173,8 @@ REGION-LENGTH is the length of the region that should be replaced with the image MEDIA-TYPE is a symbol and either 'avatar or 'media-link." ;; TODO: Cache the avatars - (let ((image-options (when (image-type-available-p 'imagemagick) + (let ((image-options (when (or (image-type-available-p 'imagemagick) + (image-transforms-p)) ; inbuilt scaling in 27.1 (cond ((eq media-type 'avatar) `(:height ,mastodon-media--avatar-height)) @@ -251,7 +255,8 @@ replacing them with the referenced image." ;; We use just an empty space as the textual representation. ;; This is what a user will see on a non-graphical display ;; where not showing an avatar at all is preferable. - (let ((image-options (when (image-type-available-p 'imagemagick) + (let ((image-options (when (or (image-type-available-p 'imagemagick) + (image-transforms-p)) ; inbuilt scaling in 27.1 `(:height ,mastodon-media--avatar-height)))) (concat (propertize " " @@ -259,7 +264,9 @@ replacing them with the referenced image." 'media-state 'needs-loading 'media-type 'avatar 'display (apply #'create-image mastodon-media--generic-avatar-data - (when image-options 'imagemagick) + (if (version< emacs-version "27.1") + (when image-options 'imagemagick) + nil) ; inbuilt scaling in 27.1 t image-options)) " "))) -- cgit v1.2.3