aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-12-16 21:14:27 +0100
committerPřemysl Eric Janouch <p@janouch.name>2023-12-16 23:50:10 +0100
commite213f0792b0d52ee9e4768cd30cf7507d5d83f37 (patch)
tree9523cff275ef3cb6478d7f06ad1be8281d9ce62e /public
parent87eb786498e598a319dfa305cf43c4ab664d26a4 (diff)
downloadgallery-e213f0792b0d52ee9e4768cd30cf7507d5d83f37.tar.gz
gallery-e213f0792b0d52ee9e4768cd30cf7507d5d83f37.tar.xz
gallery-e213f0792b0d52ee9e4768cd30cf7507d5d83f37.zip
Store image dimensions in DB
Diffstat (limited to 'public')
-rw-r--r--public/gallery.js8
-rw-r--r--public/style.css2
2 files changed, 8 insertions, 2 deletions
diff --git a/public/gallery.js b/public/gallery.js
index 1abb114..0967534 100644
--- a/public/gallery.js
+++ b/public/gallery.js
@@ -115,15 +115,20 @@ let Browse = {
let ViewModel = {
sha1: undefined,
+ width: 0,
+ height: 0,
paths: [],
tags: {},
async reload(sha1) {
this.sha1 = sha1
+ this.width = this.height = 0
this.paths = []
this.tags = {}
let resp = await call('info', {sha1: sha1})
+ this.width = resp.width
+ this.height = resp.height
this.paths = resp.paths
this.tags = resp.tags
},
@@ -185,7 +190,8 @@ let View = {
view(vnode) {
const view = m('.view', [
ViewModel.sha1 !== undefined
- ? m('img', {src: `/image/${ViewModel.sha1}`})
+ ? m('img', {src: `/image/${ViewModel.sha1}`,
+ width: ViewModel.width, height: ViewModel.height})
: "No image.",
])
return m('.container', {}, [
diff --git a/public/style.css b/public/style.css
index 7feddb2..8a42a51 100644
--- a/public/style.css
+++ b/public/style.css
@@ -36,7 +36,7 @@ ul.sidebar li.child a {
.view { display: flex; flex-grow: 1; overflow: hidden;
justify-content: center; align-items: center; }
-.view img { max-width: 100%; max-height: 100%; }
+.view img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewbar { padding: .25rem .5rem; background: #eee;
border-left: 1px solid #ccc; min-width: 20rem; overflow: auto; }