Skip to content

Instantly share code, notes, and snippets.

@henrik
Created July 15, 2025 12:56
Show Gist options
  • Save henrik/e4e1182060ec47cefeba5d4a2e6e06b4 to your computer and use it in GitHub Desktop.
Save henrik/e4e1182060ec47cefeba5d4a2e6e06b4 to your computer and use it in GitHub Desktop.
Shopify custom Liquid: Link to admin edit page; focal point preview with a link to the image page where it can be edited; weight preview.
{% comment %}
Note that the condition checking if you're an admin is very brittle.
Use at your own peril.
We mostly wanted this before launching the store, to quickly go through imported products.
{% endcomment %}
{% if content_for_header contains 'preview-bar' %}
<div style="background:#efefef">
<b>Admin:</b>
<a href="/admin/products/{{product.id}}" target="_blank">Edit</a>
<p>Focal point:<br>
<a href="/admin/content/files/{{product.featured_media.id}}" target="_blank">
<img src="{{product.featured_media | image_url: width: 600}}" style="object-fit: cover; width: 200px; height: 200px; object-position: {{product.featured_media.presentation.focal_point}}"></a></p>
<p>Weight: {{ product.first_available_variant.weight | weight_with_unit }}</p>
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment