u
This commit is contained in:
@@ -22,17 +22,17 @@ export default function addImage(provider) {
|
||||
const addArticlePicSql = isSqlite ? SQLITE_ADD_ARTICLEPIC : MSSQL_ADD_ARTICLEPIC;
|
||||
|
||||
/**
|
||||
* Adds an image to an article by its SKU, processing it into AVIF variants.
|
||||
* Adds an image to an article by its SKU, processing full, thumb, and 40px-edge small-thumb AVIF variants.
|
||||
*
|
||||
* @param {number} googleAuthId - The id of the Google auth user.
|
||||
* @param {string} sku - The article SKU.
|
||||
* @param {Buffer} image - The source image buffer.
|
||||
* @param {object} [tx] - Optional transaction to run within.
|
||||
* @returns {Promise<{picId: number, sort: number, full: {w: number, h: number, size: number}, thumb: {w: number, h: number}, fullHash: string, thumbHash: string}>} The added image info.
|
||||
* @returns {Promise<{picId: number, sort: number, full: {w: number, h: number, size: number}, thumb: {w: number, h: number}, smallThumb: {w: number, h: number}, fullHash: string, thumbHash: string}>} The added image info.
|
||||
*
|
||||
* @example
|
||||
* const result = await store.article.addImage(42, 'SKU-1', imageBuffer);
|
||||
* // => { picId, sort, full: { w, h, size }, thumb: { w, h }, fullHash, thumbHash }
|
||||
* // => { picId, sort, full: { w, h, size }, thumb: { w, h }, smallThumb: { w, h }, fullHash, thumbHash }
|
||||
*/
|
||||
return async (googleAuthId, sku, image, tx) => {
|
||||
const runAdd = async (runner) => {
|
||||
@@ -71,6 +71,9 @@ export default function addImage(provider) {
|
||||
thumbw: processed.thumb.w,
|
||||
thumbh: processed.thumb.h,
|
||||
thumbhash: processed.thumb.hash,
|
||||
smallthumbw: processed.smallThumb.w,
|
||||
smallthumbh: processed.smallThumb.h,
|
||||
smallthumbbinary: processed.smallThumb.buffer,
|
||||
source: '',
|
||||
fullbinary: processed.full.buffer,
|
||||
thumbbinary: processed.thumb.buffer,
|
||||
@@ -107,6 +110,10 @@ export default function addImage(provider) {
|
||||
w: processed.thumb.w,
|
||||
h: processed.thumb.h,
|
||||
},
|
||||
smallThumb: {
|
||||
w: processed.smallThumb.w,
|
||||
h: processed.smallThumb.h,
|
||||
},
|
||||
fullHash,
|
||||
thumbHash: processed.thumb.hash,
|
||||
};
|
||||
@@ -121,4 +128,3 @@ export default function addImage(provider) {
|
||||
return runAdd(makeRunner(provider));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user