On this page
Prepare images for your layout
Choose dimensions, cropping and image field preparation.
Before you begin: Add responsive images.
Dimension Limits and Normalization
Requested dimensions must be positive numbers. Values from 1 to 15 are treated as 16, and values above 2400 are rejected with an error. Frontbacked then normalizes valid dimensions to supported cache-friendly sizes:
The normalized value is the first supported size greater than or equal to the requested size.
| Requested | Normalized |
|---|---|
15 | 16 |
100 | 128 |
320 | 320 |
321 | 384 |
641 | 768 |
1900 | 1920 |
Use common widths such as 320, 640, 1024, 1280, and 1920 for responsive images.
When enlarge is not set, Frontbacked avoids making small originals larger. In that mode, cover behaves like crop, and contain, pad, and squeeze fall back to scale-down.
Common Patterns
Square avatar:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Post card image:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Logo that should never be cropped:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Uploads and File Fields
When a post contains a File or Blob, Frontbacked.createPost uploads it and stores file metadata on the post. Use the returned file object or the fetched post field directly as the resize source.
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Later, in a list or detail page:
For progress events, nested file fields, and resuming interrupted uploads, see Upload File.
Notes
Use the helper instead of hand-building /_fb/image URLs. Frontbacked normalizes the generated URL so repeated requests for the same source and resize options reuse the same browser and edge cache entry.
Keep original images in upload/file fields and generate resized URLs at render time. Do not save resized URLs back into posts unless your theme has a specific reason to store that derived URL.
Prepare profile photos and page images
Frontbacked.uploadProfilePhoto(file) prepares eligible photos before applying the 5 MB upload limit. It uses an accepted image format and keeps a valid original when the browser cannot optimize it.
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Use preserveImages: true to upload the original bytes. The size and format limits still apply. The page-image editor also prepares selected images before uploading; select Upload original file to skip this preparation. Page images may still be processed for display after upload.
For logos, use a size close to their display size (allowing for high-density screens), fit: "scale-down", and format: "auto". This keeps the complete logo visible without downloading a full-size image for a small header.
Images bundled with a theme
Frontbacked optimizes supported raster images when processing a theme release. Your existing image paths continue to work. Video files in the theme source are skipped. See Theme Images & Videos for supported formats and how to add video to a site.