Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I create an auto slideshow for images? #374

Open
pswpswpsw opened this issue May 18, 2020 · 3 comments
Open

Can I create an auto slideshow for images? #374

pswpswpsw opened this issue May 18, 2020 · 3 comments
Labels
enhancement An enhancement.
Milestone

Comments

@pswpswpsw
Copy link

I know how to add images in my markdown pages, and add them statically. However, how to create an autoslide show for the image gallery?

@Gothicania
Copy link

#374 (comment)

@Gothicania
Copy link

#374 (comment)

@skytheacademic
Copy link

okay so after way too much time spent on this, I came up with a weird, but usable, solution. it's not pretty, but it does the job...

First, go into maindirectory/assets/js and create a js file titled slideshow with the following code
`// slideshow.js

// Function to start the slideshow
function startSlideshow() {
let currentIndex = 0;
const images = [
'./images/img_mountains_wide.jpg',
'./images/img_nature_wide.jpg',
'./images/img_snow_wide.jpg',
// Add more image URLs here
];

const imageElement = document.getElementById('slideshow-image');

function showNextImage() {
imageElement.src = images[currentIndex];
currentIndex = (currentIndex + 1) % images.length;
}

// Start the slideshow
setInterval(showNextImage, 3000); // Change images every 3 seconds
}
`

Now, what's annoying is that you'll have to come back to this file to adjust the slideshow images and timing, but it works; make sure to add in your own image URLs. for the page you're trying to embed the slideshow in, add the following script:

`Slideshow Image

<script src="../assets/js/slideshow.js"></script> <script> startSlideshow(); // Start the slideshow </script>`

From there, push the changes and load the webpage in, and you should get a slideshow that changes slides every 3 seconds.

@rjzupkoii rjzupkoii added the enhancement An enhancement. label Feb 14, 2024
@rjzupkoii rjzupkoii added this to the v0.9 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement.
Projects
None yet
Development

No branches or pull requests

4 participants