Getting RGB value of Color from a metafield?

Hi There

I’m developing a store theme where we need to brand the collection pages for each vendor.

This is working great with Metafields - however I’m struggling to get the RGB values of the color metafields I’m using.

I’ve created a color metafield and am referencing the hex code successfully with

{{ collection.metafields.custom.font_color }}

However, when I try to use theses they return nothing

{{ collection.metafields.custom.font_color.rgb }}
or
{{ collection.metafields.custom.font_color, red }}, {{ collection.metafields.custom.font_color. green }}, {{ collection.metafields.custom.font_color.blue }}

Am I missing something, I know these work when referencing colors set in the theme editor, are we not able to do it with the color metafield?

Any suggestions welcomed.

Sean

Try

{{  collection.metafields.custom.font_color.value.rgb }}
1 Like

Thank you Jason! This worked perfectly.