I have a Hugo site and I'm using Netlify CMS to manage the content. Everytime the site builds, it runs a Gulp task that optimizes images from the src folder to the static folder. But, the problem is, when I upload an image through the CMS, it stores it in the static folder.
So, in the admin config.yml, should I set the media_folder to src/images instead?
My thinking is that the task will run and store the new minified image into the static folder but is that right? Or is there another way to do this?
Gulp task:
gulp.task('images', () => {
return gulp.src('src/images/**/*.{png,jpg,jpeg,gif,svg,webp,ico}')
.pipe($.newer('static/images'))
.pipe($.print())
.pipe($.imagemin([
$.imagemin.jpegtran({progressive: true}),
$.imagemin.optipng({optimizationLevel: 5}),
]))
.pipe(gulp.dest('static/images'));
});
Admin config.yml
media_folder: "static/images"
public_folder: "images"
In your content repository, you can make a build script (build & deploy if hosted on Netlify) and it can resize and optimise images and put them into a new folder anytime it detects new content. Most importantly, remove EXIF data such as Geolocation.