mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 01:46:51 +01:00
grunt-responsive-images and retina teaser with srcset
This commit is contained in:
parent
5758d8bee4
commit
52ddf17559
33
Gruntfile.js
33
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',
|
||||
|
@ -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
|
@ -32,7 +32,7 @@ layout: nil
|
||||
<id>{{ site.url }}/{{ post.url }}</id>
|
||||
<content type="html">
|
||||
{% if post.image %}
|
||||
<img src="{{ site.url }}/media/{{ post.image }}" />
|
||||
<img src="{{ site.url }}/media/640/{{ post.image }}" />
|
||||
{% endif %}
|
||||
|
||||
{{ post.content | xml_escape }}
|
||||
|
@ -31,7 +31,9 @@ description: 'Blog of designer & developer Matthias Kretschmann'
|
||||
<a class="photoPost" href="{{ post.url }}">
|
||||
<figure class="hmedia">
|
||||
|
||||
<img src="/media/{{ post.image }}" />
|
||||
<img
|
||||
src="/media/640/{{ post.image }}"
|
||||
srcset="/media/1280/{{ post.image }} 2x" />
|
||||
<figcaption class="entry-title fn">{{ post.title }}</figcaption>
|
||||
exif
|
||||
</figure>
|
||||
@ -50,7 +52,9 @@ description: 'Blog of designer & developer Matthias Kretschmann'
|
||||
|
||||
{% if post.image %}
|
||||
<a href="{{ post.url }}">
|
||||
<img class="teaser" src="/media/{{ post.image }}" />
|
||||
<img class="teaser"
|
||||
src="/media/640/{{ post.image }}"
|
||||
srcset="/media/1280/{{ post.image }} 2x"> />
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user