Insert images from Google Drive into Google Slides using Apps Script

Updated February 09, 2025

In this tutorial, I'll show you how easy it is to programmatically insert images from Google Drive into a Google Slides presentation using Apps Script.

In fact, this is so easy to do that the Apps Script code is just a few lines long!

Here is the code to get an image from Drive an insert it into a Google Slides presentation:

function insertImageFromDrive() {

  // Load the image from Google Drive
  var image = DriveApp.getFileById("<DRIVE_FILE_ID>");

  // Load the Google Slides presentation.
  var presentation = SlidesApp.openById("<SLIDES_ID>");

  // Insert the image into the first slide of your presentation.
  presentation.getSlides()[0].insertImage(image);
}

When you run the insertImageFromDrive() function, the image will be inserted into the first slide in your presentation.

Conclusion

In this tutorial, I showed you how easy it is to insert images from Google Drive into a Google Slides presentation using Apps Script.

DISCLAIMER: This content is provided for educational purposes only. All code, templates, and information should be thoroughly reviewed and tested before use. Use at your own risk. Full Terms of Service apply.