@@ -111,7 +111,7 @@ const getImageData = async (imageSrc) => {
111
111
} ;
112
112
113
113
// Adds the attributes to the image element
114
- const processImage = async ( imgElem , outputPath ) => {
114
+ const processImage = async ( imgElem , options ) => {
115
115
const {
116
116
transformImgPath,
117
117
className,
@@ -123,7 +123,7 @@ const processImage = async (imgElem, outputPath) => {
123
123
return ;
124
124
}
125
125
126
- const imgPath = transformImgPath ( imgElem . src , outputPath ) ;
126
+ const imgPath = transformImgPath ( imgElem . src , options ) ;
127
127
const parsedUrl = url . parse ( imgPath ) ;
128
128
let fileExt = path . extname ( parsedUrl . pathname ) . substr ( 1 ) ;
129
129
@@ -175,7 +175,7 @@ const processImage = async (imgElem, outputPath) => {
175
175
imgElem . setAttribute ( 'width' , Math . round ( ratioWidth ) ) ;
176
176
}
177
177
} catch ( e ) {
178
- console . error ( 'LazyImages' , imgPath , e ) ;
178
+ logMessage ( ` ${ e . message } : ${ imgPath } ` ) ;
179
179
}
180
180
} ;
181
181
@@ -195,7 +195,7 @@ const transformMarkup = async (rawContent, outputPath) => {
195
195
196
196
if ( images . length > 0 ) {
197
197
logMessage ( `found ${ images . length } images in ${ outputPath } ` ) ;
198
- await Promise . all ( images . map ( ( image ) => processImage ( image , outputPath ) ) ) ;
198
+ await Promise . all ( images . map ( ( image ) => processImage ( image , { outputPath } ) ) ) ;
199
199
logMessage ( `processed ${ images . length } images in ${ outputPath } ` ) ;
200
200
201
201
if ( appendInitScript ) {
@@ -222,11 +222,10 @@ const transformMarkup = async (rawContent, outputPath) => {
222
222
module . exports = {
223
223
initArguments : { } ,
224
224
configFunction : ( eleventyConfig , pluginOptions = { } ) => {
225
- lazyImagesConfig = Object . assign (
226
- { } ,
227
- defaultLazyImagesConfig ,
228
- pluginOptions
229
- ) ;
225
+ lazyImagesConfig = {
226
+ ...defaultLazyImagesConfig ,
227
+ ...pluginOptions ,
228
+ } ;
230
229
231
230
checkConfig ( lazyImagesConfig , defaultLazyImagesConfig ) ;
232
231
cache . load ( lazyImagesConfig . cacheFile ) ;
0 commit comments