diff --git a/Gruntfile.js b/Gruntfile.js index eab4830d..c0aed3b2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -83,6 +83,32 @@ module.exports = function(grunt){ } }, + responsive_images: { + production: { + options: { + sizes: [{ + name: 'small', + width: 320 + },{ + name: 'medium', + width: 640 + },{ + name: 'large', + width: 1280 + },{ + name: 'jumbo', + width: 2560 + }] + }, + files: [{ + expand: true, + cwd: '_src/_media', + src: ['**.{jpg,jpeg,gif,png}'], + custom_dest: '_site/media/{%= width %}/' + }] + } + }, + // image optimization imagemin: { assets: { @@ -185,10 +211,17 @@ module.exports = function(grunt){ 'watch' ]); + // Images only tasks + grunt.registerTask('images', [ + 'responsive_images', + 'imagemin' + ]); + // Production build grunt.registerTask('build', [ 'clean', 'jekyll', + 'responsive_images', 'imagemin', 'less', 'cmq', diff --git a/_src/_plugins/rsync_media_folder.rb b/_src/_plugins/rsync_media_folder.rb index ea79d410..ca7c1aa3 100644 --- a/_src/_plugins/rsync_media_folder.rb +++ b/_src/_plugins/rsync_media_folder.rb @@ -3,7 +3,7 @@ module Jekyll class RsyncMediaFolder < Generator def generate(site) system('mkdir -p _site'); # We may be called before _site exists. - system('rsync --archive --delete _src/_media/ _site/media/'); + system('rsync --archive _src/_media/ _site/media/'); end end end \ No newline at end of file diff --git a/_src/feed.xml b/_src/feed.xml index 105e3a7e..82937f91 100644 --- a/_src/feed.xml +++ b/_src/feed.xml @@ -32,7 +32,7 @@ layout: nil {{ site.url }}/{{ post.url }} {% if post.image %} - <img src="{{ site.url }}/media/{{ post.image }}" /> + <img src="{{ site.url }}/media/640/{{ post.image }}" /> {% endif %} {{ post.content | xml_escape }} diff --git a/_src/index.html b/_src/index.html index 3c2b4667..2188b84c 100644 --- a/_src/index.html +++ b/_src/index.html @@ -31,7 +31,9 @@ description: 'Blog of designer & developer Matthias Kretschmann'
- +
{{ post.title }}
exif
@@ -50,7 +52,9 @@ description: 'Blog of designer & developer Matthias Kretschmann' {% if post.image %}
- + /> {% endif %} diff --git a/package.json b/package.json index 4a7eb219..7ba33adf 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "grunt-jekyll": "~0.4.0", "grunt-contrib-connect": "~0.5.0", "grunt-contrib-clean": "~0.5.0", - "grunt-rsync": "~0.2.1" + "grunt-rsync": "~0.2.1", + "grunt-responsive-images": "0.0.4" }, "repository": { "type": "git",