Skip to content

Commit

Permalink
Added low res image preloading to drawings and photos.
Browse files Browse the repository at this point in the history
  • Loading branch information
KartoffelCheetah committed Feb 10, 2018
1 parent d99e5c5 commit 8fc5ba2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def photos(folder, img):
'thumbnail':pathJoin(IMAGES,THUMBNAILS,PHOTOS,url)
} for url,title in phs
]
img['thumbnail'] = pathJoin(IMAGES,THUMBNAILS,PHOTOS,img['url'])
img['url'] = pathJoin(IMAGES,PHOTOS,img['url'])
except Exception as e:
print('\x1b[31m', e, '\x1b[0m')
Expand Down Expand Up @@ -130,6 +131,7 @@ def drawings(img):
'thumbnail':pathJoin(IMAGES,THUMBNAILS,DRAWINGS,url)
} for url,title in phs
]
img['thumbnail'] = pathJoin(IMAGES,THUMBNAILS,DRAWINGS,img['url'])
img['url'] = pathJoin(IMAGES,DRAWINGS,img['url'])
except Exception as e:
print('\x1b[31m', e, '\x1b[0m')
Expand Down
7 changes: 7 additions & 0 deletions static/css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,20 @@ body {
}
#TheImage canvas,
#TheImage img {
position: relative;
max-width: 100%;
max-height: 100%;
display: block;
margin: auto;
padding: 2px;
border: 2px solid #d2d2d2;
}
#TheImage canvas[aria-hidden],
#TheImage img[aria-hidden] {
position: absolute;
top: 0;
left: 0;
}
.photo-desc,
.photo-meta {
padding: 0.7rem;
Expand Down
5 changes: 5 additions & 0 deletions static/css/photos.styl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@
cursor: pointer
background-color: primaryColorD3
canvas,img
position: relative
max-width: 100%
max-height: 100%
display: block
margin: auto
padding: 2px
border: 2px solid primaryColor
canvas[aria-hidden],img[aria-hidden]
position: absolute
top: 0
left: 0
.photo-desc,
.photo-meta
padding: mediumWidth
Expand Down
3 changes: 2 additions & 1 deletion templates/drawings.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<div class="wrap-photos">
<header>{{img.title}}</header>
<div id="TheImage">
<img src="{{staticPATH+img.url}}" alt="{{img.title}}">
<img src="{{staticPATH+img.thumbnail}}" aria-hidden="true" width="{{img.xres}}">
<img src="{{staticPATH+img.url}}" alt="{{img.title}}" onload="$('#TheImage img[aria-hidden]').hide()">
</div>
<div class="photo-main">
<div class="photo-slider">
Expand Down
3 changes: 2 additions & 1 deletion templates/photos.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<div class="wrap-photos">
<header>{{img.title}}</header>
<div id="TheImage">
<img src="{{staticPATH+img.url}}" alt="{{img.title}}">
<img src="{{staticPATH+img.thumbnail}}" aria-hidden="true" width="{{img.xres}}">
<img src="{{staticPATH+img.url}}" alt="{{img.title}}" onload="$('#TheImage img[aria-hidden]').hide()">
</div>
<div class="photo-main">
<div class="photo-slider">
Expand Down

0 comments on commit 8fc5ba2

Please sign in to comment.