From f077ec43437df33f07c1a15b7e4988616d0e138d Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Mon, 2 May 2016 13:59:31 +0200 Subject: [PATCH] Add overlay_filter param to hero headers The `overlay_filter` param lets you darken or otherwise filter the hero header picture to make the text content pop out more. You can use it by specifying the opacity (between 0 and 1) of a black overlay like so: ```yaml excerpt: "This post should display a **header with an overlay image**, if the theme supports it." header: overlay_image: unsplash-image-1.jpg overlay_filter: 0.5 # same as adding an opacity of 0.5 to a black background caption: "Photo credit: [**Unsplash**](https://unsplash.com)" cta_label: "More Info" cta_url: "https://unsplash.com" ``` Or if you want to do more fancy things, go full rgba: ```yaml excerpt: "This post should display a **header with an overlay image**, if the theme supports it." header: overlay_image: unsplash-image-1.jpg overlay_filter: rgba(255, 0, 0, 0.5) caption: "Photo credit: [**Unsplash**](https://unsplash.com)" cta_label: "More Info" cta_url: "https://unsplash.com" ``` --- _includes/page__hero.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/_includes/page__hero.html b/_includes/page__hero.html index ef0f4ca5..fb90c3cf 100644 --- a/_includes/page__hero.html +++ b/_includes/page__hero.html @@ -18,8 +18,14 @@ {% capture overlay_img_path %}{{ page.header.overlay_image | prepend: "/images/" | prepend: base_path }}{% endcapture %} {% endif %} +{% if page.header.overlay_filter contains "rgba" %} + {% capture overlay_filter %}{{ page.header.overlay_filter }}{% endcapture %} +{% elsif page.header.overlay_filter %} + {% capture overlay_filter %}rgba(0, 0, 0, {{ page.header.overlay_filter }}){% endcapture %} +{% endif %} +
{% if page.header.overlay_color or page.header.overlay_image %}
@@ -46,4 +52,4 @@ {% if page.header.caption %} {{ page.header.caption | markdownify | remove: "

" | remove: "

" }}
{% endif %} -
\ No newline at end of file +