|||

Cannot Divide by Zero in Peak Picture Partial

When assets don’t contain valid images that can be processed by Glide (which can happen by migration or by not setting up proper sanitation rules for asset field uploads), a white screen of death due to a division will occur.

This happened to me in various scenarios:

  • A migration of legacy data created assets without actual images
  • Images were uploaded in TIFF format
  • Images were uploaded without extension
  • A file’s extension doesn’t match its mime_type

This happens because the picture partial tries to divide height by width to get the original image’s ratio. To prevent this, we could just wrap the original height calculation within a simple if statement:

{{ if height && width }}
    {{ original_ratio = height / width }}
{{ /if }}
Up next Applying a Growth Mindset (Doodle) Expand Basic Markdown Formatting in Apple Notes
Latest posts Pros and Cons of Reflect Notes App A Love Letter to Sublime Internet Lazy.so is an amazing tool. Here's why I don't keep it Look Around You Don’t ask what the world needs Carl Sagan has shown the absurdity of not acting against climate change back in 1990 On the plus sides of being a web designer Friday Deployment A success message that communicates the opposite of success Do not demand to be appreciated Craft Docs vs Bear Notes Figma AI Rant Epomaker TH80 Pro Polyamor, aber mit PKM apps 🫣 Ironie, die Fabi Rommel Helft der Natur Stimmen im Kopf - Flohmarkt croox website online Tiny Garden Paradise Oktober in Europa Figma Rant: forever assembling iCloud Drive Rant Schwiegerfuchs Same Vibe Tailwind and Web Craftsmanship Buttons with CSS Expand Basic Markdown Formatting in Apple Notes Cannot Divide by Zero in Peak Picture Partial Applying a Growth Mindset (Doodle) When Gmail Messages deleted in Apple Mail keep coming back