Conditional code to test if checkbox is ticked

Hi everyone,

I know that this is a php forum but as I’m having trouble with a small amount of liquid code (ie. shopify) and can’t find help elsewhere, I thought that I might be able to find out some information here (since both php and liquid are programming languages).

I’m trying to write some conditional code to output some html based on whether a checkbox is ticked or not. The name of the checkbox is “Image Position” (as you can see in the code below).

Even though the checkbox is ticked, the code is still outputting “background-position: center top” when it should be outputting “background-position: center center”.

Can anyone help me troubleshoot this code as I’m hoping it’s similar to php?

Would really appreciate any advice.

             <div style="background-image: url({{this['Image 1'] | asset_url }}); 
             {%- if this['Image Position'] == true -%} 
             background-position: center center   {%- else -%}
             background-position: center top {%- endif -%};">

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.