Skip to main content
Shopify hosts your product images on cdn.shopify.com. By proxying that origin through Tenbyte CDN, you get on-the-fly resizing, format conversion, and faster regional delivery without changing how you upload products.

How the integration works

The tenbyte.liquid snippet rewrites Shopify CDN URLs to Tenbyte URLs and appends transform params.

Prerequisites

  • A Shopify store with theme edit access.
  • A Tenbyte distribution with Image Optimizer enabled.
  • Backup your theme before editing — Online Store → Themes → ”…” → Download theme file.

1. Add Shopify as an origin

In your Tenbyte distribution → OriginsAdd Origin:
FieldValue
Origin NameOrigin-Shopify
TypeHostname
Domain / IPhttps://cdn.shopify.com
Add Shopify as an Origin
Save. Your Tenbyte CDN domain can now fetch and optimize Shopify-hosted images.
Distribution URL

2. Add Tenbyte settings to the theme

In Shopify Admin → Online Store → Themes, find your theme, click ”…” → Edit code. Open Config/settings_schema.json, scroll to the bottom, and append this block. Save.
settings_schema.json
{
  "name": "Tenbyte",
  "settings": [
    {
      "type": "paragraph",
      "content": "Tenbyte Image Optimization. See https://docs.tenbyte.io/docs/cdn/image-optimization/integration-guide/shopify"
    },
    {
      "type": "checkbox",
      "id": "enableTenbyte",
      "label": "Enable Tenbyte"
    },
    {
      "type": "text",
      "id": "tenbyteUrl",
      "label": "Tenbyte URL endpoint",
      "info": "Your Tenbyte distribution. Example: https://your-distribution.tenbytecdn.com/"
    },
    {
      "type": "text",
      "id": "tenbyteShopifyCdnUrl",
      "label": "Shopify CDN domain",
      "info": "Leave as //cdn.shopify.com unless you have a proxy in place."
    }
  ]
}

3. Create the tenbyte.liquid snippet

In Snippets, create tenbyte.liquid and paste:
tenbyte.liquid
{% capture TENBYTE %}
  {% if settings.enableTenbyte %}
    {% for i in (1..1) %}
      {% unless src or settings.tenbyteUrl != blank %}
        {{ src }}{% break %}
      {% endunless %}

      {% assign cdnUrl = settings.tenbyteShopifyCdnUrl | strip %}
      {% unless src contains cdnUrl %}
        {{ src }}{% break %}
      {% endunless %}

      {% assign tenbyteUrl = settings.tenbyteUrl | strip %}

      {% assign filters = 'w,h,q,fm,fit,dpr,format,quality,bri,con,sat,sharp,blur,auto' | split:',' %}
      {% assign imgWithQuerystring = "?" %}
      {% if src contains '?' %}{% assign imgWithQuerystring = '' %}{% endif %}

      {% for _filter in filters %}
        {% if [_filter] %}
          {% assign imgWithQuerystring = imgWithQuerystring | append:_filter | append:'=' | append:[_filter] | append:'&' %}
        {% endif %}
      {% endfor %}

      {% assign modifySrc = src | split:'?' | first | append:"?" %}
      {% assign newSrc = modifySrc | strip | replace:cdnUrl,tenbyteUrl | append:imgWithQuerystring %}
    {% endfor %}

    {{ newSrc | default:src }}
  {% else %}
    {{ src }}
  {% endif %}
{% endcapture %}{{ TENBYTE | strip | replace:'  ' | strip_newlines }}

4. Enable Tenbyte in theme settings

Online Store → Themes → Customize. In the left panel, open the Tenbyte section under General settings:
FieldValue
Enable Tenbyte
Tenbyte URL endpointhttps://your-distribution.tenbytecdn.com/
Shopify CDN domain//cdn.shopify.com

5. Update theme image renders

Replace direct image renders with the snippet. The before/after pattern: Before:
{{ product.featured_image }}
After:
{% assign feat_img_url = product.featured_image | image_url %}
{% render 'tenbyte', src: feat_img_url, w: 600 %}

Responsive srcset example

{% assign feat_img_url = product.featured_image | image_url %}

<img
  src="{% render 'tenbyte', src: feat_img_url, w: 960 %}"
  srcset="
    {% render 'tenbyte', src: feat_img_url, w: 320  %} 320w,
    {% render 'tenbyte', src: feat_img_url, w: 480  %} 480w,
    {% render 'tenbyte', src: feat_img_url, w: 640  %} 640w,
    {% render 'tenbyte', src: feat_img_url, w: 960  %} 960w,
    {% render 'tenbyte', src: feat_img_url, w: 1280 %} 1280w,
    {% render 'tenbyte', src: feat_img_url, w: 1600 %} 1600w"
  sizes="(min-width: 990px) 800px, calc(100vw - 4rem)"
  alt="{{ media.preview_image.alt | escape }}"
  loading="lazy" />

Verify

  1. Open a product page.
  2. View source / inspect element.
  3. Confirm image URLs go to your-distribution.tenbytecdn.com instead of cdn.shopify.com.
  4. In DevTools Network, check content-type: image/webp on supported browsers.
# Or test directly
curl -sSI "https://your-distribution.tenbytecdn.com/s/files/1/.../photo.jpg?w=480&fm=auto" \
  | grep -iE 'content-type|x-cache'

Operational tips

  • Ship behind the checkbox. The enableTenbyte toggle lets you roll back instantly.
  • Test in a draft theme. Edit a copy, preview, then publish.
  • Watch cache hit ratio. Shopify pages reuse images aggressively; CHR should climb past 95%.
  • Cap widths. Match Shopify’s preset image sizes (320, 480, 640, 960, 1280, 1600) so you don’t fragment the cache.
  • Lazy-load below the fold. loading="lazy" is supported in Liquid <img> tags.

Troubleshooting

SymptomFix
Images still hit cdn.shopify.comenableTenbyte is off or tenbyteUrl is blank in theme settings.
404 from TenbyteOrigin not added or wrong path; the path on Tenbyte must match Shopify’s.
Layout shiftsAdd width and height to <img> so the browser reserves space.
Broken themeRestore from the backup you took in step 0.