|||

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 Back to MyMind Sending Articles from Feedbin to Readwise Reader In Praise of Sublime App Why I Ended Up Using Todoist Yet Again 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 Carl Sagan has shown the absurdity of not acting against climate change back in 1990 A success message that communicates the opposite of success Epomaker TH80 Pro Polyamor, aber mit PKM apps 🫣 Ironie, die Fabi Rommel Helft der Natur Tiny Garden Paradise 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) Using the AVIF format for CSS background images Workaround for Email Validation Issue in Statamic A First Quick Look at Cosmos.so – and Why I'll Stick with MyMind Install a Starter Kit from local repo to get the latest Peak working in Statamic 4 beta Set sensible validations for Statamic image uploads Render first heading inside Statamic Page Builder as `h1` My PKM App Stack for 2023 Favorite apps in recent weeks: mymind & Craft First List Item inside CSS Multi Column Layout is offset