Skip to content

Commit 648254b

Browse files
committed
Add support for captioning images in feature row helper
Use `image_caption` YAML front matter to assign a caption to the feature image, Markdown is allowed. Close #1440
1 parent bcde2d7 commit 648254b

File tree

6 files changed

+44
-10
lines changed

6 files changed

+44
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Enhancements
44

5+
* Add support for captioning images in feature row helper via `image_caption` YAML Front Matter. [#1440](https://github.com/mmistakes/minimal-mistakes/issues/1440)
56
* Add [Google Custom Search Engine](https://cse.google.com/cse) support. [#1652](https://github.com/mmistakes/minimal-mistakes/issues/1652)
67
* Update Font Awesome to version [`5.0.13`](https://github.com/FortAwesome/Font-Awesome/blob/master/CHANGELOG.md)
78
* Add "Pets" sample archive page to documentation site. [#1664](https://github.com/mmistakes/minimal-mistakes/pull/1664)

_includes/feature_row

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
"{{ f.image_path | relative_url }}"
2626
{% endif %}
2727
alt="{% if f.alt %}{{ f.alt }}{% endif %}">
28+
{% if f.image_caption %}
29+
<span class="archive__item-caption">{{ f.image_caption | markdownify | remove: "<p>" | remove: "</p>" }}</span>
30+
{% endif %}
2831
</div>
2932
{% endif %}
3033

_sass/minimal-mistakes/_archive.scss

+27
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,40 @@
6363
}
6464

6565
.archive__item-teaser {
66+
position: relative;
6667
border-radius: $border-radius;
6768
overflow: hidden;
69+
6870
img {
6971
width: 100%;
7072
}
7173
}
7274

75+
.archive__item-caption {
76+
position: absolute;
77+
bottom: 0;
78+
right: 0;
79+
margin: 0 auto;
80+
padding: 2px 5px;
81+
color: #fff;
82+
font-family: $caption-font-family;
83+
font-size: $type-size-8;
84+
background: #000;
85+
text-align: right;
86+
z-index: 5;
87+
opacity: 0.5;
88+
border-radius: $border-radius 0 0 0;
89+
90+
@include breakpoint($large) {
91+
padding: 5px 10px;
92+
}
93+
94+
a {
95+
color: #fff;
96+
text-decoration: none;
97+
}
98+
}
99+
73100
/*
74101
List view
75102
========================================================================== */

docs/_docs/14-helpers.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ feature_row:
3030
- image_path: /assets/images/unsplash-gallery-image-3-th.jpg
3131
title: "Placeholder 3"
3232
excerpt: "This is some sample content that goes here with **Markdown** formatting."
33-
last_modified_at: 2018-03-20T16:00:09-04:00
33+
last_modified_at: 2018-05-15T15:36:46-04:00
3434
toc: true
3535
toc_label: "Helpers"
3636
toc_icon: "cogs"
@@ -134,15 +134,16 @@ Designed to compliment the [`splash`]({{ "/docs/layouts/#splash-page-layout" | r
134134

135135
To add a feature row containing three content blocks with text and image, add the following YAML Front Matter
136136

137-
| Name | Required | Description | Default |
138-
| ---- | ----------- | ----------- | ------- |
139-
| **image_path** | **Required** | Full path to image eg: `/assets/images/filename.jpg`. Use absolute URLS for those hosted externally. | |
140-
| **alt** | Optional | Alternate text for image. | |
141-
| **title** | Optional | Content block title. | |
142-
| **excerpt** | Optional | Content block excerpt text. Markdown is allowed. | |
143-
| **url** | Optional | URL that the button should link to. | |
144-
| **btn_label** | Optional | Button text label. | `more_label` in UI Text data file. |
145-
| **btn_class** | Optional | Button style. See [utility classes]({{ "/docs/utility-classes/#buttons" | relative_url }}) for options. | `btn` |
137+
| Name | Required | Description | Default |
138+
| ---- | ----------- | ----------- | ------- |
139+
| **image_path** | **Required** | Full path to image eg: `/assets/images/filename.jpg`. Use absolute URLS for those hosted externally. | |
140+
| **image_caption** | Optional | Caption for image, Markdown is supported eg: `"Image from [Unsplash](https://unsplash.com)" | |
141+
| **alt** | Optional | Alternate text for image. | |
142+
| **title** | Optional | Content block title. | |
143+
| **excerpt** | Optional | Content block excerpt text. Markdown is allowed. | |
144+
| **url** | Optional | URL that the button should link to. | |
145+
| **btn_label** | Optional | Button text label. | `more_label` in UI Text data file. |
146+
| **btn_class** | Optional | Button style. See [utility classes]({{ "/docs/utility-classes/#buttons" | relative_url }}) for options. | `btn` |
146147

147148
```yaml
148149
feature_row:

docs/_docs/18-history.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ toc: true
1212

1313
### Enhancements
1414

15+
* Add support for captioning images in feature row helper via `image_caption` YAML Front Matter. [#1440](https://github.com/mmistakes/minimal-mistakes/issues/1440)
1516
* Add [Google Custom Search Engine](https://cse.google.com/cse) support. [#1652](https://github.com/mmistakes/minimal-mistakes/issues/1652)
1617
* Update Font Awesome to version [`5.0.13`](https://github.com/FortAwesome/Font-Awesome/blob/master/CHANGELOG.md)
1718
* Add "Pets" sample archive page to documentation site. [#1664](https://github.com/mmistakes/minimal-mistakes/pull/1664)

test/_pages/splash-page.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ intro:
1515
- excerpt: 'Nullam suscipit et nam, tellus velit pellentesque at malesuada, enim eaque. Quis nulla, netus tempor in diam gravida tincidunt, *proin faucibus* voluptate felis id sollicitudin. Centered with `type="center"`'
1616
feature_row:
1717
- image_path: assets/images/unsplash-gallery-image-1-th.jpg
18+
image_caption: "Image courtesy of [Unsplash](https://unsplash.com/)"
1819
alt: "placeholder image 1"
1920
title: "Placeholder 1"
2021
excerpt: "This is some sample content that goes here with **Markdown** formatting."

0 commit comments

Comments
 (0)