Google Sheets
Thumbnail Generator offers a Google Sheets integration, which allows you to generate thumbnails directly from your spreadsheet.
Setting up the integration
- Get an API key for Thumbnail Generator
- In your spreadsheet, in each sheet where you want to use Thumbnail Generator, create a column to use for triggering thumbnail generation, a column for the generated thumbnail URL, and optionally a column for the template IDs
- In the Google Sheets menu, navigate to Extensions > Apps Script
- In the code editor, paste the following:
function generateThumbnailOnEdit(e) {
const OPTIONS = {
// --- CONFIGURATION ---
triggerColumnName: "Generate Thumbnail", // Name of the column used to trigger thumbnail generation
triggerValue: "TRUE", // Value used to trigger thumbnail generation
thumbnailUrlColumnName: "Thumbnail URL", // Name of the column for the generated thumbnail URL
templateId: "abcd1234", // ID of the thumbnail template to use globally (set to null if using a column)
templateIdColumnName: "Template ID", // Name of the column with the template ID to use (set to null if using a global template ID)
apiKey: "YOUR_API_KEY", // Your API key for Thumbnail Generator
headerRow: 1, // The index of the header row in the spreadsheet (starts at 1)
thumbnailWidth: 1920, // Width in pixels of the thumbnail to generate
thumbnailHeight: 1080, // Height in pixels of the thumbnail to generate
// --- END CONFIGURATION ---
event: e
};
try {
eval(UrlFetchApp.fetch('https://assets.thumbgen.jwp.services/integrations/google-sheets.js').getContentText());
} catch (error) {
Logger.log(`An error occurred: ${error.message}`);
Logger.log(`Stack: ${error.stack}`);
}
}
- Edit the parameters between the
CONFIGURATIONtags according to your setup - Click "Save project to Drive"
- Navigate to Triggers > Add a trigger
- Under "Choose which function to run" select
generateThumbnailOnEdit - Under "Select event type" select "On edit" and click Save
Using the integration
- To generate a thumbnail, set a cell under a column with your configured trigger column name as the header to the value you configured as the trigger value.
- Tip: You can use checkboxes to make this process easier.
- All values from the row will be sent to Thumbnail Generator and made available under
data, using the header names as keys.- Any non-alphanumeric characters in the header names will be replaced with underscores, for example
Hello World!would becomeHello_World_. - Additionally, the sheet name is available under
data.sheetNameand the row number is available underdata.rowNumber
- Any non-alphanumeric characters in the header names will be replaced with underscores, for example
- The URL to the generated thumbnail will be populated under the column name you configured
- If the thumbnail generation fails, the error message will be populated under the thumbnail URL column you configured