简体   繁体   中英

Get pictures from google drive folder with javascript to my website

I would like to be able to take pictures from folder on google drive and run it on my website.

I have a java script slider but I have no idea how to take the pictures from google drive until now I took it from local folder.

This is the java script:

<img class="mySlides myImg"  src="Images/Image_01.jpeg" alt="Pasta, Tasty" width="620" height="340">

 <!-- Slider Image Script -->
                 <script>
                 var slideIndex = 1;
                 showDivs(slideIndex);

                 function plusDivs(n) {
                 showDivs(slideIndex += n);
                 }

                 function currentDiv(n) {
                 showDivs(slideIndex = n);
                 }

                 function showDivs(n) {
                 var i;
                 var x = document.getElementsByClassName("mySlides");
                 var dots = document.getElementsByClassName("demo");
                 if (n > x.length) {slideIndex = 1}    
                 if (n < 1) {slideIndex = x.length}
                 for (i = 0; i < x.length; i++) {
                     x[i].style.display = "none";  
                  }
                 for (i = 0; i < dots.length; i++) {
                 dots[i].className = dots[i].className.replace(" w3-white", "");
                 }
                 x[slideIndex-1].style.display = "block";  
                 dots[slideIndex-1].className += " w3-white";
                 }
                 </script>

来自Google云端硬盘的托管资源已长期停用 ,但是对于图像,您可以尝试使用“ 文件”:获取要获取的webContentLink ,然后将其显示在img src中,例如:

< img src="https://drive.google.com/uc?id=FILE_ID_HERE&export=download" >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM