Skip to content

E-commerce Grid Template

Display multiple products or images in a grid layout.

Template ID

template: "grid"

Preview

Multi-image layout featuring:

  • 2-4 product/image grid
  • Collection title
  • Clean, balanced layout
  • Professional styling

Parameters

ParameterTypeRequiredDescription
titlestringYesCollection/category title
subtitlestringNoDescription or count
grid_imagesarrayNoArray of 2-4 image URLs
grid_titlestringNoGrid section title
themestringNodark (default) or light
logo_urlstringNoBrand logo

Example Request

bash
curl -X POST https://ogimageapi.io/api/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "title": "Summer Collection 2024",
    "subtitle": "24 new arrivals",
    "grid_images": [
      "https://example.com/product1.jpg",
      "https://example.com/product2.jpg",
      "https://example.com/product3.jpg",
      "https://example.com/product4.jpg"
    ],
    "template": "grid",
    "theme": "dark"
  }' \
  --output collection-og.png

Layout Structure

4 Images

┌─────────────────────────────────────────┐
│                                         │
│   Summer Collection 2024         [Logo] │
│   24 new arrivals                       │
│                                         │
│   ┌─────────┐  ┌─────────┐              │
│   │ Image 1 │  │ Image 2 │              │
│   └─────────┘  └─────────┘              │
│   ┌─────────┐  ┌─────────┐              │
│   │ Image 3 │  │ Image 4 │              │
│   └─────────┘  └─────────┘              │
│                                         │
└─────────────────────────────────────────┘

2 Images

┌─────────────────────────────────────────┐
│   Collection Title               [Logo] │
│                                         │
│   ┌────────────┐  ┌────────────┐        │
│   │            │  │            │        │
│   │  Image 1   │  │  Image 2   │        │
│   │            │  │            │        │
│   └────────────┘  └────────────┘        │
│                                         │
└─────────────────────────────────────────┘

Theme Variations

Dark Theme

  • Products pop against dark background
  • Modern, premium feel
  • Great for tech, fashion

Light Theme

  • Clean, minimal look
  • Traditional e-commerce feel
  • Better for home, lifestyle

Use Cases

ContextRecommended Setup
Product collections4 images
Category pages4 images
New arrivals2-4 images
Lookbooks4 images
Property galleries4 images

Best Practices

  1. Consistent image style — Same lighting, angles
  2. 4 images is ideal — Best visual balance
  3. Square images work best — Will be cropped to fit
  4. Avoid busy images — Simple backgrounds

Integration Example

Collection OG Generator

javascript
async function generateCollectionOG(collection) {
  // Get first 4 product images
  const images = collection.products
    .slice(0, 4)
    .map(p => p.images[0]?.src)
    .filter(Boolean);
  
  const response = await fetch('https://ogimageapi.io/api/generate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': process.env.OG_IMAGE_API_KEY
    },
    body: JSON.stringify({
      title: collection.title,
      subtitle: `${collection.products_count} products`,
      grid_images: images,
      template: 'grid',
      theme: 'dark',
      logo_url: 'https://mystore.com/logo.png'
    })
  });
  
  return response;
}

Category Pages

javascript
// Generate OG images for all category pages
async function generateCategoryImages(categories) {
  for (const category of categories) {
    const topProducts = await getTopProductsInCategory(category.id, 4);
    
    const og = await generateCollectionOG({
      title: category.name,
      products: topProducts,
      products_count: category.total_count
    });
    
    // Save image...
  }
}

Image Specifications

PropertyRecommendation
FormatPNG or JPG
Size400×400 px minimum per image
Aspect ratio1:1 (square) ideal
BackgroundClean/white preferred
File sizeUnder 500KB each

Generate stunning Open Graph images programmatically.