Skip to content

Instantly share code, notes, and snippets.

@shopifypartners
Created September 25, 2019 07:19
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 shopifypartners/bde45cb27ef36d430c563e1afdd7b248 to your computer and use it in GitHub Desktop.
Save shopifypartners/bde45cb27ef36d430c563e1afdd7b248 to your computer and use it in GitHub Desktop.
How to use Shopify theme settings to create mobile-specific logos |
<div id="desktop">
{% if section.settings.logo != blank %}
{% capture image_size %}{{ section.settings.logo_max_width }}x{% endcapture %}
<img src="{{ section.settings.logo | img_url: image_size }}"
srcset="{{ section.settings.logo | img_url: image_size }} 1x, {{ section.settings.logo | img_url: image_size, scale: 2 }} 2x"
alt="{{ section.settings.logo.alt | default: shop.name }}">
{% else %}
{{ shop.name }}
{% endif %}
</div>
<div id="mobile">
{% if section.settings.mobile_logo != blank %}
{% capture image_size %}{{ section.settings.mobile_logo_max_width }}x{% endcapture %}
<img src="{{ section.settings.mobile_logo | img_url: image_size }}"
srcset="{{ section.settings.mobile_logo | img_url: image_size }} 1x, {{ section.settings.mobile_logo | img_url: image_size, scale: 2 }} 2x"
alt="{{ section.settings.logo.alt | default: shop.name }}">
{% else %}
{{ shop.name }}
{% endif %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment