diff --git a/app/views/markup/_image_card.html.slim b/app/views/markup/_image_card.html.slim
index 766861452..a0f5fea50 100644
--- a/app/views/markup/_image_card.html.slim
+++ b/app/views/markup/_image_card.html.slim
@@ -2,4 +2,4 @@
.about-module-box-panel
p.govuk-body-l
= text
- .about-module-box-panel style="min-height: 150px; background-image: url(#{image})"
+ .about-module-box-panel title=title style="min-height: 150px; background-image: url(#{image})"
diff --git a/config/initializers/markdown.rb b/config/initializers/markdown.rb
index f7c24ef61..055277044 100644
--- a/config/initializers/markdown.rb
+++ b/config/initializers/markdown.rb
@@ -52,6 +52,8 @@ def two_thirds
# @example
# {image_card}
+ # This is the title
+ #
# This is the body copy
#
# //path/to/image
@@ -61,9 +63,8 @@ def two_thirds
def image_card
pattern = build_regexp('image_card')
@output = output.gsub(pattern) do
- text, image = split_content Regexp.last_match(1)
-
- image_card_template.render(nil, text: text, image: image)
+ title, text, image = *Regexp.last_match(1).strip.split("\n")
+ image_card_template.render(nil, title: title, text: text, image: image)
end
self
end
diff --git a/spec/helpers/content_helper_spec.rb b/spec/helpers/content_helper_spec.rb
index 4b9a8d884..0c1fd0ecf 100644
--- a/spec/helpers/content_helper_spec.rb
+++ b/spec/helpers/content_helper_spec.rb
@@ -114,6 +114,25 @@
expect(html).to include '2 Pages'
end
end
+
+ describe 'Image card' do
+ let(:input) do
+ <<~MARKUP
+ {image_card}
+ This is the image card title
+
+ This is image text
+
+ //This is the image
+
+ {/image_card}
+ MARKUP
+ end
+
+ it 'renders a title' do
+ expect(html).to include 'title="This is the image card title"'
+ end
+ end
end
describe 'Not found error' do