Display Variant Metafield - List of Multiple Files (Images) on Product Page

For anyone else who has this issue, I ended up figuring it out for myself! The code I used is just a compilation of various code snippets I found around this forum, combined through a lot of trial and error! It is still a work in progress as I can’t figure how to add styles to it through CSS to centre align it, so if anyone has any suggestions let me know :slightly_smiling_face:

I entered the below code in a custom liquid block in my theme customisation. Replace the values in " " with your own.

{% for variant in product.variants %}
{%- if product.selected_or_first_available_variant.id == variant.id and variant.metafields.[your metafield key] != blank -%}
{% assign file = variant.metafields.[your metafield key].value %}
{% for image in variant.metafields.[your metafield key].value %}

{% endfor %}
{%- endif -%}
{% endfor %}