diff --git a/src/routes/_components/profile/AccountProfileHeader.html b/src/routes/_components/profile/AccountProfileHeader.html
index fdebf62e..89a171e6 100644
--- a/src/routes/_components/profile/AccountProfileHeader.html
+++ b/src/routes/_components/profile/AccountProfileHeader.html
@@ -1,6 +1,10 @@
Name and following
store,
@@ -118,6 +140,37 @@
bot: ({ account }) => !!account.bot,
label: ({ bot }) => bot ? 'bot' : ''
},
+ methods: {
+ async onAvatarClick () {
+ const { account } = this.get()
+ const { avatar, avatar_static: avatarStatic, display_name: displayName, username } = account
+ const [showMediaDialog, nativeDimensions] = await Promise.all([
+ importShowMediaDialog(),
+ getImageNativeDimensions(avatarStatic)
+ ])
+ // pretend this is a media attachment so it will work in the media dialog
+ const { width, height } = nativeDimensions
+ const mediaAttachments = [
+ {
+ description: `Avatar for ${displayName || username}`,
+ type: 'image',
+ preview_url: avatarStatic,
+ url: avatar,
+ meta: {
+ original: {
+ width,
+ height
+ },
+ small: {
+ width: 100,
+ height: 100
+ }
+ }
+ }
+ ]
+ showMediaDialog(mediaAttachments, /* index */ 0)
+ }
+ },
components: {
Avatar,
ExternalLink,
diff --git a/src/routes/_utils/getImageNativeDimensions.js b/src/routes/_utils/getImageNativeDimensions.js
new file mode 100644
index 00000000..c5defa63
--- /dev/null
+++ b/src/routes/_utils/getImageNativeDimensions.js
@@ -0,0 +1,11 @@
+import { decodeImage } from './decodeImage'
+
+export async function getImageNativeDimensions (url) {
+ const img = document.createElement('img')
+ img.src = url
+ await decodeImage(img)
+ return {
+ width: img.naturalWidth,
+ height: img.naturalHeight
+ }
+}