Replace Shapes With Image
Replaces all shapes containing specific text with images in a Google Slides presentation.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Presentation Id - The ID of the Google Slides presentation where shapes will be replaced with images.
- Text to Replace - The text content that identifies which shapes should be replaced with images.
- Replacement Image Url - The URL of the image that will replace the matching shapes.
Options
- Search case sensitivity - If enabled, the text search is case-sensitive; otherwise, it's case-insensitive.
- Image Replace Method - The method used to fit the replacement image:
- Center Inside - Scales the image to fit entirely within the original shape boundaries while maintaining aspect ratio
- Center Crop - Scales and crops the image to fill the original shape boundaries while maintaining aspect ratio
- Page Object Ids - An array of page IDs to limit the replacement operation to specific slides. If empty, all slides in the presentation are searched.
How It Works
The Replace Shapes With Image node finds all shapes containing the specified text and replaces them with images from the provided URL. When executed, the node:
- Validates the provided inputs (Presentation Id, Text to Replace, Replacement Image Url)
- Connects to the specified Google Slides presentation
- Searches for all shapes containing the specified text across the presentation or specified pages
- Replaces each matching shape with the image from the provided URL
- Applies the specified image fitting method to each replacement
Requirements
- A valid Google Slides presentation ID
- Valid Google Slides API credentials
- Text content that identifies the shapes to be replaced
- A publicly accessible URL for the replacement image
- Proper permissions to modify the presentation
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Presentation Id
- Empty or invalid Text to Replace
- Empty or invalid Replacement Image Url
- Google Slides API authentication errors
- Insufficient permissions to modify the presentation
- Invalid presentation ID
- No shapes found containing the specified text
- Google Slides service errors
Usage Notes
- The Presentation Id can be found in the URL of the Google Slides presentation
- The Text to Replace is searched within shape content, not necessarily visible text
- The Replacement Image Url must be publicly accessible (not behind authentication)
- When Page Object Ids is specified, only those slides are searched for matching shapes
- The Image Replace Method determines how the new image fits within each original shape:
- Center Inside - Ensures the entire replacement image is visible but may leave empty space
- Center Crop - Fills the entire original shape area but may crop parts of the replacement image
- This node is particularly useful for template-based presentations where placeholder shapes need to be replaced with actual images
- The replaced images maintain the position and size of the original shapes
- Supported image formats include JPG, PNG, GIF, and other web-friendly formats
- If no matching shapes are found, the node returns an error
Examples
Example 1: Replace Logo Placeholder
Replace a shape containing "LOGO" with an actual logo image:
Presentation Id: "1ABC..."
Text to Replace: "{{LOGO}}"
Replacement Image Url: "https://example.com/images/company-logo.png"
Image Replace Method: CENTER_INSIDE
Finds all shapes containing "{{LOGO}}" and replaces them with the logo image, ensuring the full logo is visible.
Example 2: Replace Product Images with Crop
Replace product placeholder shapes with actual product photos:
Presentation Id: "1ABC..."
Text to Replace: "{{PRODUCT_IMAGE}}"
Replacement Image Url: "https://example.com/products/item-123.jpg"
Image Replace Method: CENTER_CROP
Fills the shape completely with the product image, cropping if necessary to maintain the shape dimensions.
Example 3: Replace on Specific Slides
Replace image placeholders only on designated slides:
Presentation Id: "1ABC..."
Text to Replace: "{{CHART}}"
Replacement Image Url: "https://example.com/charts/sales-q4.png"
Page Object Ids: ["p2", "p5"]
Image Replace Method: CENTER_INSIDE
Replaces chart placeholders only on slides 2 and 5.
Example 4: Case-Sensitive Replacement
Use case sensitivity to replace specific placeholders:
Presentation Id: "1ABC..."
Text to Replace: "HEADER_IMAGE"
Replacement Image Url: "https://example.com/headers/main.jpg"
Search case sensitivity: true
Image Replace Method: CENTER_CROP
Only replaces shapes containing exactly "HEADER_IMAGE" in uppercase.
Tips for Effective Use
- Unique Markers: Use unique placeholder text in shapes that won't appear elsewhere in the presentation
- Image Hosting: Ensure images are hosted on reliable, publicly accessible URLs
- Image Dimensions: Pre-size images to match expected placeholder dimensions for best results
- Replace Method Selection:
- Use CENTER_INSIDE for logos and images where full visibility is critical
- Use CENTER_CROP for background images and photos where filling the space is more important
- Testing URLs: Test image URLs in a browser before using them in automation
- Shape Preparation: Create template shapes with clear placeholder text for easy identification
Common Use Cases
Use Case 1: Dynamic Product Presentations
Generate product presentations with actual product images:
// Load product data
const products = [
{ name: "Widget A", image: "https://cdn.example.com/widget-a.jpg" },
{ name: "Widget B", image: "https://cdn.example.com/widget-b.jpg" }
];
for (const product of products) {
// Copy template presentation
msg.presentationId = msg.newPresentationId;
// Replace product name
// (Use Replace Text node)
// Replace product image
msg.imageUrl = product.image;
// Use Replace Shapes With Image node with placeholder "{{PRODUCT_IMAGE}}"
}
Use Case 2: Personalized Reports with Charts
Replace chart placeholders with generated chart images:
// Generate charts and upload to accessible URL
const chartUrl = await generateAndUploadChart(msg.salesData);
msg.presentationId = "1ABC...";
msg.chartPlaceholder = "{{SALES_CHART}}";
msg.chartImageUrl = chartUrl;
// Use Replace Shapes With Image to insert the chart
Use Case 3: Client Logo Integration
Replace generic logo placeholders with client-specific logos:
const clients = [
{ name: "Acme Corp", logo: "https://assets.example.com/logos/acme.png" },
{ name: "Tech Start", logo: "https://assets.example.com/logos/techstart.png" }
];
for (const client of clients) {
// Copy template
msg.presentationId = msg.clientPresentationId;
// Replace client name and logo
msg.logoUrl = client.logo;
// Replace shapes containing "{{CLIENT_LOGO}}"
}
Use Case 4: Screenshot Integration
Replace placeholder shapes with automated screenshots:
// Workflow that captures screenshots
// 1. Browser automation captures dashboard screenshot
// 2. Upload screenshot to cloud storage
// 3. Get public URL
const screenshotUrl = msg.uploadedScreenshotUrl;
// Replace placeholder with screenshot
msg.placeholderText = "{{DASHBOARD_SCREENSHOT}}";
msg.imageUrl = screenshotUrl;
// Use Replace Shapes With Image node
Use Case 5: Map and Location Images
Replace location placeholders with map images:
// Generate static map URL
const location = msg.officeAddress;
const mapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${encodeURIComponent(location)}&zoom=15&size=640x480&key=YOUR_API_KEY`;
msg.mapPlaceholder = "{{LOCATION_MAP}}";
msg.mapImageUrl = mapUrl;
// Replace shapes with map image
Understanding Image Replace Methods
CENTER_INSIDE
- Scales image to fit completely within shape bounds
- Maintains image aspect ratio
- May leave empty space if aspect ratios don't match
- Best for: Logos, icons, charts, images where nothing should be cropped
CENTER_CROP
- Scales image to fill entire shape
- Maintains image aspect ratio
- Crops excess to fit shape
- Best for: Photos, backgrounds, images where filling the space is priority
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "Presentation ID cannot be empty" | No ID provided or ID is "_" | Ensure valid Presentation Id is provided |
| "Text to replace cannot be empty" | Empty search text | Provide valid placeholder text |
| "Replacement image URL cannot be empty" | No image URL provided | Ensure a valid publicly accessible image URL is provided |
| "No matching text found" | Shape with placeholder doesn't exist | Verify placeholder text exists in shapes; check case sensitivity |
| Image not loading | URL not publicly accessible | Ensure image URL doesn't require authentication; test in browser |
| Permission denied on image | Image URL requires credentials | Use publicly accessible URLs or upload to cloud storage first |
| Invalid image format | Unsupported image type | Use standard formats: JPG, PNG, GIF, SVG |
| Image appears distorted | Wrong replace method for aspect ratio | Try switching between CENTER_INSIDE and CENTER_CROP |
Best Practices
- Placeholder Visibility: Make placeholder text visible in template shapes for easy identification
- Image Preparation: Optimize images for web before using (compress, resize appropriately)
- URL Reliability: Use reliable hosting services (Google Drive, AWS S3, Cloudinary, etc.)
- Aspect Ratios: Design template shapes with aspect ratios matching expected images
- Batch Processing: When replacing multiple images, ensure all URLs are valid before starting
- Error Handling: Implement fallback images for cases where primary images aren't available
- Testing: Always test with sample data before processing large batches
- Performance: For large presentations, consider limiting replacements to specific slides using Page Object Ids
Advanced Workflow Integration
Complete Image Replacement Workflow
- Prepare Template: Create presentation with shapes containing placeholder text
- Copy Template: Use Copy Presentation to create working instance
- Upload Images: Upload or generate images and get public URLs
- Replace Shapes: Use Replace Shapes With Image for each placeholder
- Quality Check: Optionally export to PDF or review in browser
- Distribute: Share or export the final presentation
Dynamic Chart Integration
// Complete workflow for chart integration
// 1. Query data from database
const salesData = await querySalesData();
// 2. Generate chart image using chart library
const chartBuffer = await generateChartImage(salesData);
// 3. Upload to cloud storage
const chartUrl = await uploadToCloudStorage(chartBuffer, 'sales-chart.png');
// 4. Copy presentation template
// (Use Copy Presentation node)
// 5. Replace chart placeholder
msg.chartPlaceholder = "{{SALES_CHART}}";
msg.chartUrl = chartUrl;
// (Use Replace Shapes With Image node)
// 6. Replace data text
// (Use Replace Text nodes for metrics)