@@ -69,28 +69,25 @@ def generate(site)
6969 FileUtils ::mkdir_p ( imgdir_destination + imgfile_relative_path )
7070 outfile_fullpath_webp = File . join ( imgdir_destination + imgfile_relative_path , outfile_filename )
7171
72- # Keep the webp file from being cleaned by Jekyll
73- site . static_files << WebpFile . new ( site ,
74- site . dest ,
75- File . join ( imgdir , imgfile_relative_path ) ,
76- outfile_filename )
77-
7872 # Check if the file already has a webp alternative?
7973 # If we're force rebuilding all webp files then ignore the check
8074 # also check the modified time on the files to ensure that the webp file
8175 # is newer than the source file, if not then regenerate
82- next if !@config [ 'regenerate' ] && File . file? ( outfile_fullpath_webp ) &&
83- File . mtime ( outfile_fullpath_webp ) > File . mtime ( imgfile )
84-
85- if ( File . file? ( outfile_fullpath_webp ) &&
86- File . mtime ( outfile_fullpath_webp ) <= File . mtime ( imgfile ) )
76+ if @config [ 'regenerate' ] || !File . file? ( outfile_fullpath_webp ) ||
77+ File . mtime ( outfile_fullpath_webp ) <= File . mtime ( imgfile )
8778 Jekyll . logger . info "WebP:" , "Change to source image file #{ imgfile } detected, regenerating WebP"
88- end
8979
90- # Generate the file
91- WebpExec . run ( @config [ 'flags' ] , imgfile , outfile_fullpath_webp )
92- file_count += 1
93-
80+ # Generate the file
81+ WebpExec . run ( @config [ 'quality' ] , @config [ 'flags' ] , imgfile , outfile_fullpath_webp )
82+ file_count += 1
83+ end
84+ if File . file? ( outfile_fullpath_webp )
85+ # Keep the webp file from being cleaned by Jekyll
86+ site . static_files << WebpFile . new ( site ,
87+ site . dest ,
88+ File . join ( imgdir , imgfile_relative_path ) ,
89+ outfile_filename )
90+ end
9491 end # dir.foreach
9592 end # img_dir
9693
0 commit comments