1
Hello! I have a slide that works normally. Only I have to keep passing him the link of each image.
What I wanted to do is put a path from a folder so it can identify the png or jpg files and automatically display them with javascript.
The Code is like this:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.7/css/swiper.min.css">
<style>
html, body {
position: relative;
height: 100%;
}
body {
background: #000;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color:#000;
margin: 0;
padding: 0;
}
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
overflow: hidden;
}
</style>
</head>
<body>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-zoom-container">
<img src="http://lorempixel.com/800/800/sports/1/">
</div>
</div>
<div class="swiper-slide">
<div class="swiper-zoom-container">
<img src="http://lorempixel.com/800/400/sports/2/">
</div>
</div>
<div class="swiper-slide">
<div class="swiper-zoom-container">
<img src="http://lorempixel.com/400/800/sports/3/">
</div>
</div>
</div>
<div class="swiper-pagination swiper-pagination-white"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.7/js/swiper.min.js"></script>
<script>
var swiper = new Swiper('.swiper-container', {
zoom: true,
pagination: {
el: '.swiper-pagination',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
</script>
The folder is on the server? I believe you should use some language on the server, php .... . If you use javascript and it runs in the browser, you do not have access to the file system.
– N. Dias
It’s in a local folder. I can’t use PHP, because I’m developing for an app.
– OliverDamon
Will run in a browser?
– N. Dias
Yes. Then I need it to be in Javascript. To identify the pages in a folder and play them right on the slide.
– OliverDamon
One solution would be to use a input file Multiple, then you would have access to all the files, but you would have to select them
– N. Dias
But I will not upload directly. I would manually place images in the folder. I would only play the images inside and the slide would recognize.
– OliverDamon
Only with Javascript in the client-side you don’t have access to the file system.
– N. Dias
This link can help https://stackoverflow.com/questions/31274329/get-list-of-filenames-in-folder-with-javascript
– N. Dias
If pulling from a specific page. Type a link?
– OliverDamon