Skip to content

Instantly share code, notes, and snippets.

@dominikwilkowski
Created February 13, 2014 01:52
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 dominikwilkowski/8968287 to your computer and use it in GitHub Desktop.
Save dominikwilkowski/8968287 to your computer and use it in GitHub Desktop.
This snippet lookes at its input string and returns either the input or a fallback image in a specific size, no path though
{% comment %}
This snippet lookes at its input string and returns either the input or a fallback image in a specific size, no path though
Usage:
{% assign newImageSize = "medium" %} (optional)
{% include 'make-image' with imageString %}
Return:
{{ newImageSize }} (either as input or fallback)
Required:
Fallback images with the following naming:
no-image-pico.gif
no-image-icon.gif
no-image-thumb.gif
no-image-small.gif
no-image-compact.gif
no-image-medium.gif
no-image-large.gif
no-image-grande.gif
no-image-1024x1024.gif
no-image-2048x2048.gif
{% endcomment %}
{% assign newImage = make-image %}
{% if newImageSize == nil %}
{% assign newImageSize = "medium" %}
{% endif %}
{% if newImage.size == nil %}
{% capture newImage %}no-image-{{ newImageSize }}.gif{% endcapture %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment