如果有人已经回答了,我很抱歉。我看了看,但可能有不好的搜索条件。
我如何使用谷歌驱动器中的图片作为谷歌应用程序脚本中的按钮,该脚本将HTML作为Web应用程序?
我知道我必须使用以下内容来获取要显示的图像,例如横幅:
在HTML文件中:
<script>
//for showing the image
google.script.run
.withSuccessHandler( function(bytes){ showImage(bytes) })
.loadImageBytes();
function showImage(bytes){
document.getElementById("headerimage").src = "data:image/png;base64," + bytes;
$("#headerimage").fadeIn(2500);
}</script>
在服务器端:
//For displaying an image from our Google Drive
function loadImageBytes(){
//https://drive.google.com/a/boxwood.org/file/d/1ewu8FAmyIGooL4cXH4ki6CuVKE5v_4HC/view?usp=sharing
var id = "1ewu8FAmyIGooL4cXH4ki6CuVKE5v_4HC"
var bytes = DriveApp.getFileById(id).getBlob().getBytes();
return Utilities.base64Encode(bytes);
}
但是,如何为样式表中的按钮设置图像?
/* Edit Buttons */
.edit_button {
display: inline-block;
height: 20px;
width: 20px;
padding: 0;
margin: 0;
vertical-align: top;
background-image: url( 'https://drive.google.com/a/boxwood.org/file/d/1sR7PUHUiTlcWarlm4Ks-SXF2j5EUACwe' );
background-size: 20px 20px;
}