Skip to main content

Google Sheets

Thumbnail Generator offers a Google Sheets integration, which allows you to generate thumbnails directly from your spreadsheet.

Setting up the integration​

  1. Get an API key for Thumbnail Generator
  2. 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
  3. In the Google Sheets menu, navigate to Extensions > Apps Script
  4. 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}`);
}
}
  1. Edit the parameters between the CONFIGURATION tags according to your setup
  2. Click "Save project to Drive"
  3. Navigate to Triggers > Add a trigger
  4. Under "Choose which function to run" select generateThumbnailOnEdit
  5. 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 become Hello_World_.
    • Additionally, the sheet name is available under data.sheetName and the row number is available under data.rowNumber
  • 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