Compare commits

...

2 Commits

Author SHA1 Message Date
DebaucheryLibrarian 36a8adbd8c 1.185.1 2021-03-16 04:35:31 +01:00
DebaucheryLibrarian 586ff6d4bd Calculating tag photo dimensions in seed file, improved tag photo lazy loading. 2021-03-16 04:35:26 +01:00
5 changed files with 33 additions and 7 deletions

View File

@ -10,9 +10,11 @@
class="photo-link" class="photo-link"
> >
<img <img
:src="`/img/${photo.thumbnail}`" :src="getPath(photo, 'thumbnail', { local: true })"
:style="{ 'background-image': `url(/img/${photo.thumbnail})` }" :style="{ 'background-image': `url(${getPath(photo, 'lazy', { local: true })})` }"
:alt="photo.comment" :alt="photo.comment"
:width="photo.width"
:height="photo.height"
class="photo" class="photo"
@load="$emit('load', $event)" @load="$emit('load', $event)"
> >
@ -122,6 +124,7 @@ export default {
.poster, .poster,
.photo { .photo {
width: auto;
max-height: 15rem; max-height: 15rem;
max-width: 100%; max-width: 100%;
box-shadow: 0 0 3px var(--shadow-weak); box-shadow: 0 0 3px var(--shadow-weak);

View File

@ -39,6 +39,8 @@ function initTagsActions(store, _router) {
thumbnail thumbnail
lazy lazy
path path
width
height
comment comment
entity { entity {
id id
@ -69,6 +71,8 @@ function initTagsActions(store, _router) {
thumbnail thumbnail
lazy lazy
path path
width
height
comment comment
entity { entity {
id id
@ -160,6 +164,8 @@ function initTagsActions(store, _router) {
thumbnail thumbnail
comment comment
lazy lazy
width
height
entity { entity {
id id
name name

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "traxxx", "name": "traxxx",
"version": "1.185.0", "version": "1.185.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "1.185.0", "version": "1.185.1",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@casl/ability": "^5.2.2", "@casl/ability": "^5.2.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "traxxx", "name": "traxxx",
"version": "1.185.0", "version": "1.185.1",
"description": "All the latest porn releases in one place", "description": "All the latest porn releases in one place",
"main": "src/app.js", "main": "src/app.js",
"scripts": { "scripts": {

View File

@ -1,4 +1,7 @@
// const nanoid = require('nanoid/non-secure'); const path = require('path');
const Promise = require('bluebird');
const sharp = require('sharp');
const upsert = require('../src/utils/upsert'); const upsert = require('../src/utils/upsert');
const sfw = Object.entries({ const sfw = Object.entries({
@ -951,13 +954,27 @@ exports.seed = knex => Promise.resolve()
[entity.slug]: entity, [entity.slug]: entity,
}), {}); }), {});
const { inserted, updated } = await upsert('media', tagMedia.map(media => ({ const tagMediaWithDimensions = await Promise.map(tagMedia, async (media) => {
const { width, height } = await sharp(path.join('public/img', media.path)).metadata(); // size not available from filepath
return {
...media,
width,
height,
};
}, {
concurrency: 20,
});
const { inserted, updated } = await upsert('media', tagMediaWithDimensions.map(media => ({
id: media.id, id: media.id,
path: media.path, path: media.path,
thumbnail: media.thumbnail, thumbnail: media.thumbnail,
lazy: media.lazy, lazy: media.lazy,
mime: media.mime, mime: media.mime,
index: media.index, index: media.index,
width: media.width,
height: media.height,
comment: media.comment, comment: media.comment,
entity_id: entitiesBySlug[media.entitySlug]?.id, entity_id: entitiesBySlug[media.entitySlug]?.id,
})), 'path', knex); })), 'path', knex);