-
Notifications
You must be signed in to change notification settings - Fork 1
/
EnlargeImage.js
38 lines (35 loc) · 916 Bytes
/
EnlargeImage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Created by: RemcoE33
https://github.com/RemcoE33/apps-script-codebase
Select the cell that contains the =IMAGE formula, then run this function to enlage the image.
*/
function onOpen(e){
SpreadsheetApp.getUi()
.createMenu('Utill')
.addItem('Enlarge', 'enlargeImage')
.addToUi()
}
function enlargeImage() {
const formula = SpreadsheetApp.getActiveSpreadsheet().getActiveCell().getFormula();
const url = /IMAGE\(\"(.*?)\"/g.exec(formula)[1];
const html = `
<!DOCTYPE html>
<html>
<head>
<style>
img {
max-width: 100%;
max-height: 100%;
}
</style>
<base target="_top">
</head>
<body>
<div class=img>
<img src="${url}">
</div>
</body>
</html>
`
SpreadsheetApp.getUi().showDialog(HtmlService.createHtmlOutput(html).setHeight(500).setWidth(800));
}