Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.