Cat Photo Slideshow

A new random cat photo every few seconds.
Show me a new cat photo every
Sure! A new cat photo is coming your way in
All photos provided by:
Copy this doc
to modify it!
How it works
The wonderful folks at Cat as a service () provide a simple API for requesting a random cat photo: . Coda (trying to be helpful) caches images it fetches, so that if you try to add multiple images with that same URL you’ll only get a random cat the first time you add it to the doc, and a copy of it every other time. To get around this we need to do some cache busting. This is the process of adding a value to each URL that will make it unique, therefore causing Coda to fetch a new copy, and get a new cat.
An easy way to get a unique string is to utilize the current date and time, since it will never repeat. However I don’t want the cats to fly by every millisecond, so we’ll need to do some rounding so that the time is only unique every few seconds. Using some of the Date formulas we can do just that!
Time Rounded to Minute:
Rounding the time down to the nearest minute, since we’ll be handling the seconds separately.
Now(”minute”) =>
12/7/2022 2:36 PM
Rounded Seconds:
Using the value of the slider at the top of the doc, round the seconds to the nearest interval.
Floor(Now("seconds").Second() / [Seconds Per Cat]) * [Seconds Per Cat] =>
Rounded Time:
Combine the two values above to compute the rounded time.
[Time Rounded to Minute] + Seconds([Rounded Seconds]) =>
12/7/2022 2:36:30 PM
Rounded Time as Number:
Convert the time to a number, since that’s easier to plug into a URL (no spaces).
[Rounded Time].ToNumber() =>
Cat Image URL:
Put the time at the end of the URL in a fake parameter called now that just ignores.
Format("{1}", [Rounded Time as Number]) =>
Cat Image:
The last step is to use that URL to embed an image, which is what you see above.
[Cat Image URL].Image(height:400) =>

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.