Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklchaves/589cf392b5076d46b5fc0037bff7e74e to your computer and use it in GitHub Desktop.
Save marklchaves/589cf392b5076d46b5fc0037bff7e74e to your computer and use it in GitHub Desktop.
First Attempt to Support Art Direction Mobile First Images on Minimal Mistakes Jekyll Theme
<!-- Process the Hero Image -->
{% if page.header.overlay_image_mob %}
{% if page.header.overlay_image_mob
contains "://" %}
{% capture overlay_img_mob_path %}{{ page.header.overlay_image }}{% endcapture %}
{% elsif page.header.overlay_image_mob %}
{% capture overlay_img_mob_path %}{{ page.header.overlay_image_mob | relative_url }}{% endcapture %}
{% endif %}
{% else %}
{% capture overlay_img_mob_path %}{{ overlay_img_path }}{% endcapture %}
{% endif %}
<!-- Mobile First Responsive Web Design for Hero -->
<style>
/* Kick-in the larger landscape hero only when needed. */
@media screen and (min-width: 768px) {
.page__hero--overlay {
{% if page.header.overlay_color %}
background-color: {{ page.header.overlay_color | default: 'transparent' }};
{% endif %}
{% if overlay_img_path %}
background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}),
{% endif %}url({{ overlay_img_path }}) !important; /* Not sure why need to force this. */
{% endif %}
}
}
/* Default to mobile (art direction) version if provided. */
.page__hero--overlay {
{% if page.header.overlay_color %}
background-color: {{ page.header.overlay_color | default: 'transparent' }};
{% endif %}
{% if overlay_img_mob_path %}
background-image: {% if overlay_filter %}linear-gradient({{ overlay_filter }}, {{ overlay_filter }}),
{% endif %}url('{{ overlay_img_mob_path }}');
{% endif %}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment