Skip to content

Commit 26f8ea5

Browse files
Added Image Modal (#59)
Co-authored-by: miguel <[email protected]>
1 parent 9ab2ba8 commit 26f8ea5

File tree

7 files changed

+2248
-1
lines changed

7 files changed

+2248
-1
lines changed

_includes/head.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
{%- seo -%}
66
<link rel="stylesheet" href="{{ "/assets/css/style.css" | relative_url }}">
77
<link rel="icon" type="image/png" href="{{ "/assets/favicon.png" | relative_url }}" />
8+
<link rel="stylesheet" href="{{ "/assets/css/magnific-popup.css" | relative_url }}">
89
{%- feed_meta -%}
910
{%- if jekyll.environment == 'production' and site.google_analytics -%}
1011
{%- include google-analytics.html -%}
1112
{%- endif -%}
13+
<script src="https://code.jquery.com/jquery-3.2.0.min.js"></script>
14+
<script src="{{ "/assets/js/jquery.magnific-popup.js" | relative_url }}"></script>
1215
</head>

_layouts/post.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,28 @@ <h3>
6464

6565
document.getElementById('animated-post-description').style.display = 'initial';
6666
typeWriter();
67+
68+
// Image modal
69+
var $imgs = [];
70+
$('img').each(function(idx) {
71+
var obj = {
72+
src: $(this).attr('src')
73+
}
74+
$imgs.push(obj);
75+
var elem = $(this);
76+
$(this).click(function() {
77+
$('.modal').magnificPopup('open', idx);
78+
});
79+
});
80+
81+
$('.modal').magnificPopup({
82+
items: $imgs,
83+
type: 'image',
84+
closeOnContentClick: true,
85+
mainClass: 'mfp-img-mobile',
86+
image: {
87+
verticalFit: true
88+
}
89+
90+
});
6791
</script>

_posts/2019-04-16-welcome-to-jekyll2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ print_hi('Tom')
4141

4242
Pictures look like this:
4343

44-
![image](https://picsum.photos/200)
44+
![image](https://picsum.photos/200){: .modal}
4545

4646
Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].
4747

_sass/dash/_layout.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,8 @@ ul.related-posts {
369369
}
370370
color: $color-yellow;
371371
}
372+
}
373+
374+
.modal{
375+
cursor: pointer;
372376
}

0 commit comments

Comments
 (0)