Using media filters on metafield file type

Solved
molten_frog
New Member
9 0 0

Hi,

I have the following:

{% assign product_image = product.selected_or_first_available_variant.metafields.my_fields.image_1 %}
 
According to this link https://shopify.dev/api/liquid/objects/generic-file I should be able to do {{ product_image.media_type }} but this doesn't return anything.
 
Does anyone know if what I am trying to do is possible?
 
Kind regards
Michael
 
 
 
 
Accepted Solution (1)

Accepted Solutions
LitExtension
Shopify Partner
1933 313 389

This is an accepted solution.

Hi @molten_frog,

Please change code:

{% assign product_image = product.selected_or_first_available_variant.metafields.my_fields.image_1 %}

=>

{% assign product_image = product.selected_or_first_available_variant.metafields.my_fields.image_1.value %}

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!

View solution in original post

Replies 5 (5)
LitExtension
Shopify Partner
1933 313 389

This is an accepted solution.

Hi @molten_frog,

Please change code:

{% assign product_image = product.selected_or_first_available_variant.metafields.my_fields.image_1 %}

=>

{% assign product_image = product.selected_or_first_available_variant.metafields.my_fields.image_1.value %}

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!

View solution in original post

molten_frog
New Member
9 0 0

You are an absolute hero. Not the first time you have helped me

LitExtension
Shopify Partner
1933 313 389

Hi @molten_frog,

If you have any difficulty, you can contact me.

Happy to help you.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
molten_frog
New Member
9 0 0

Thanks @LitExtension I really appreciate it.

I have uploaded an mp4 to variant_media_1. And similar to the code above I have done the following:

{% assign product_video = product.selected_or_first_available_variant.metafields.my_fields.variant_media_1.value %}
 
However, product_video.media_type returns generic_file rather than video?
LitExtension
Shopify Partner
1933 313 389

Hi @molten_frog,

The generic_file object can be returned when a metafield has a file_reference type. If the file_reference is not an image of type JPEG, PNG, or GIF, then it will return a generic_file.

Refer https://i.imgur.com/8iiOqCc.png

Hope it is clear to you.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!