|||

Set sensible validations for Statamic image uploads

By default, Statamic asset fields don’t validate size or file type. Recently I’ve had a bit of trouble with large image files clogging up the Git repo and image color being off due to the client uploading huge Tiff files.

To prevent this from now on, I decided to limit image uploads to the jpeg and png MIME types and add a maximum file size of ~20M.

validate:
  - 'mimetypes:image/jpeg,image/png'
  - 'max_filesize:20000'

It’s probably a good idea to define some validation rules that fit your project and provide them by default to prevent problems in the future.

PS: I generate webp versions for each image served, that’s why I don’t allow more modern formats to be uploaded. This way I can make sure to always have a format that is supported everywhere as a fallback.

Up next Render first heading inside Statamic Page Builder as `h1` Say you have a headline field on various Page Builder elements, and one as a set of in a Bard field. Both should visually look the same. Install a Starter Kit from local repo to get the latest Peak working in Statamic 4 beta I needed to do this to install the latest Statamic Peak into the Statamic v4 beta. Clone the Starter Kit (read: Statamic Peak) Repo locally I also
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