lib/images.js
/** 
 * For imgObj adds attributes (tumbnails and original file)
 *
 * @returns Promise
 */
For imgObj adds attributes (tumbnails and original file)
@returns Promise
For imgObj adds attributes ( tumbnails and original file ) @returns Promise
function processImg(imgObj, cacheFolder) {
    let ret = undefined;
    const src = (imgObj.attrs.filter(_=>_.name==='rifs-original')[0] || imgObj.attrs.filter(_=>_.name==='src')[0] || {}).value;
    const srcSize = sizeOf(src);
    if (srcSize.height > 100) {
      ret = sharp(src)
        .resize(20)
        .toFormat('png')
        .toBuffer()
        .then( srcStub => {
          addOrReplace( imgObj.attrs, "rifs-stub", 'data:image/png;base64,' + srcStub.toString('base64'));
          addOrReplace( imgObj.attrs, "rifs-original", src);
          addOrReplace( imgObj.attrs, "src", getCacheFileName(src, 800, cacheFolder));
        })
        .then( () => {
          return generateCache(src, cacheFolder);
        })
    }
    return ret;
}
function processImg ( imgObj , cacheFolder ) { let ret = undefined ; const src = ( imgObj . attrs . filter ( _ => _ . name === 'rifs-original' ) [ 0 ] || imgObj . attrs . filter ( _ => _ . name === 'src' ) [ 0 ] || { } ) . value ; const srcSize = sizeOf ( src ) ; if ( srcSize . height > 100 ) { ret = sharp ( src ) . resize ( 20 ) . toFormat ( 'png' ) . toBuffer ( ) . then ( srcStub => { addOrReplace ( imgObj . attrs , "rifs-stub" , 'data:image/png;base64,' + srcStub . toString ( 'base64' ) ) ; addOrReplace ( imgObj . attrs , "rifs-original" , src ) ; addOrReplace ( imgObj . attrs , "src" , getCacheFileName ( src , 800 , cacheFolder ) ) ; } ) . then ( ( ) => { return generateCache ( src , cacheFolder ) ; } ) } return ret ; }
For imgObj adds attributes (tumbnails and original file)
 @returns Promise
For imgObj adds attributes ( tumbnails and original file ) @returns Promise