[www] Gallery page updated
This commit is contained in:
1 parent
6fa8564cc8
commit
597e87896e
6 files changed
+75
-38
No files matched your search
+18
-5
@@ -4,6 +4,7 @@ const ImageArtifactType = require('./ImageArtifactType')
|
||||
const {find, findOne} = require('../lib/store')
|
||||
|
||||
const previewTypes = [
|
||||
ImageArtifactType.SMALL,
|
||||
ImageArtifactType.MEDIUM,
|
||||
ImageArtifactType.BIG,
|
||||
ImageArtifactType.ORIGIN,
|
||||
@@ -31,14 +32,26 @@ const previewFromImage = (imgs = []) => imgs.length
|
||||
: null
|
||||
|
||||
const processAlbum = async album => {
|
||||
let preview = {}
|
||||
// {
|
||||
// data: [
|
||||
// {
|
||||
// url: null,
|
||||
// width: 0,
|
||||
// height: 0,
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
|
||||
const previewImageId = album.preview ? album.preview : previewFromImage(album.images)
|
||||
let preview
|
||||
if (previewImageId) {
|
||||
const image = await Image.findById(previewImageId)
|
||||
preview = image.findArtifact(previewTypes)
|
||||
} else {
|
||||
preview = {
|
||||
url: null,
|
||||
if (image) {
|
||||
// const imageArtifacts = image.findArtifact(previewTypes)
|
||||
// if (imageArtifacts) {
|
||||
// preview = imageArtifacts
|
||||
// }
|
||||
preview = image.getPicture(ImageArtifactType.SMALL)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Data = require('./Data')
|
||||
const ImageArtifactType = require('./ImageArtifactType')
|
||||
const {findOne} = require('../lib/store')
|
||||
const {mapOf} = require('../lib/common')
|
||||
|
||||
@@ -32,6 +33,26 @@ class Image {
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
getPicture(size) {
|
||||
const retinaSize = ImageArtifactType.retina(size)
|
||||
|
||||
const a = this.getArtifact(size)
|
||||
const a2 = this.getArtifact(retinaSize)
|
||||
const pic = {
|
||||
src: a.url,
|
||||
width: a.width,
|
||||
height: a.height,
|
||||
set: [
|
||||
{
|
||||
url: a2.url,
|
||||
density: ImageArtifactType.RETINA_DENSITY,
|
||||
}
|
||||
]
|
||||
}
|
||||
console.log(pic)
|
||||
return pic
|
||||
}
|
||||
}
|
||||
|
||||
class ImageArtifact {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
class ImageArtifact {
|
||||
class ImageArtifactType {
|
||||
constructor() {
|
||||
throw new Error('Cannot create instance of ImageArtifact')
|
||||
throw new Error('Cannot create instance of ImageArtifactType')
|
||||
}
|
||||
}
|
||||
|
||||
ImageArtifact.MEDIUM = 'medium'
|
||||
ImageArtifact.BIG = 'big'
|
||||
ImageArtifact.ORIGIN = 'origin'
|
||||
ImageArtifactType.SMALL = 'small'
|
||||
ImageArtifactType.MEDIUM = 'medium'
|
||||
ImageArtifactType.BIG = 'big'
|
||||
ImageArtifactType.ORIGIN = 'origin'
|
||||
|
||||
module.exports = ImageArtifact
|
||||
ImageArtifactType.RETINA_DENSITY = 2
|
||||
ImageArtifactType.retina = type => `${type}@${ImageArtifactType.RETINA_DENSITY}`
|
||||
|
||||
module.exports = ImageArtifactType
|
||||
Reference in new issue
Block a user