I've tried looking around but I can't find anything I can understand. I'm quite a newbie when it comes to gulp and stuff, as I mainly use it to automate a couple of tasks for front end dev so I've managed to make it work with the few things I needed (sass, watch, browser-sync), but I now wanted to add imagemin to my gulpfile.js and here comes the issue.
I've been able to make it work with the standard syntax
// Optimise Images
gulp.task('imagemin', function() {
var imgSrc = 'wp-content/themes/solid-theme-child/img/*.+(png|jpg|gif)',
imgDst = 'wp-content/themes/solid-theme-child/img/opt';
gulp.src(imgSrc)
.pipe(changed(imgDst))
.pipe(imagemin())
.pipe(gulp.dest(imgDst));
});
I mainly work with WordPress and I would like to scan the whole /wp-content/uploads folder and its subfolders, but the problem is that I can't define a specific output folder since /uploads/ contains many folders sorted by month, and a new one is being added every month. I would like to scan all of these and optimise the images inside, then replace the original images with their optimised version without creating copies in any specific predefined folder.
Sorry for the dumb question, if I could have figured this out myself I wouldn't have asked but I really don't know how to do it, I hope you understand.
Thank you very much!