Adjust image size in a custom liquid

Topic summary

A user is experiencing image alignment issues with custom liquid code used for product metafields. The images display correctly on desktop but lose formatting on mobile devices.

Technical Details:

  • Custom liquid code uses product.metafields.custom.imagem_problema_solucao with an 800px image URL
  • Current styling includes display:block with auto margins

Solution Provided:

  • Add max-width property to the <img> markup to ensure responsive behavior across devices

Status: Issue appears resolved after the suggested fix was provided.

Summarized with AI on November 20. AI used: claude-sonnet-4-5-20250929.

Hey guys,

I am using metafilds in a custom liquid to put custom texts on product descriptions. However, I have a problem with image alignment. It fits perfectly with the desktop, but on mobile it is formatted without formatting. Can anyone help me?

My site is: www.smartcasashop.com.br/products/new-mini-heater-household-small-heat-blower-desktop-office-portable-temperature-control-multifunctional-heater

The custom code I’m using is:

<img style=“display: block; margin-left: auto; margin-right: auto; width: auto” src={{product.metafields.custom.imagem_problema_solu_o | img_url: ‘800x’}}>

Desktop

Mobile

Hi, you should add max-width to your code, try this one:


2 Likes

Thanks, @drakedev !

1 Like