mirror of
https://github.com/parnic/MMM-Unsplash.git
synced 2026-11-30 00:20:49 +00:00
Show a random photo from an Unsplash collection
- JavaScript 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
load() runs every updateInterval and called img1.addEventListener("load")
each time without removing the previous listener. Because the two images
swap ids after each fade, listeners accumulated on both (2 per hour at the
default interval), and every stacked copy ran on each new photo: N
concurrent fades, and N id swaps, which leave the ids unswapped when N is
even. Assigning img1.onload replaces the previous handler instead.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| MMM-Unsplash.js | ||
| package.json | ||
| README.md | ||
MMM-Unsplash
A MagicMirror² module used to pull a random photo from one or more Unsplash collections. Like MMM-RandomPhoto, but for specific collections. Tested with MagicMirror² v2.2.2, v2.3.1 servers, Chrome 65 on Windows 10 and Midori 0.4.3 on a Raspberry Pi Zero W with Raspbian Jessie.
Installation
- Navigate into your MagicMirror's
modulesfolder and executegit clone https://github.com/parnic/MMM-Unsplash.git. - Add the module inside
config.jsplacing it where you prefer.
Config
| Option | Type | Description | Default |
|---|---|---|---|
opacity |
double | The opacity of the image. | 0.3 |
collections |
string | (REQUIRED) Comma-delimited list of collections to pull from. | '' |
width |
int | Desired image width. | 1080 |
height |
int | Desired image height. | 1920 |
orientation |
string | Orientation of the image. Valid values: landscape, portrait, squarish |
'portrait' |
apiKey |
string | (REQUIRED) Your Unsplash API key. | '' |
updateInterval |
int | Number of seconds between image updates. Note that your API key is rate-limited, so if, for example, your rate limit was 50/hr, this should be no less than 72. | 1800 (30mins) |
divName |
string | The ID of the div to use for the displayed image. This only needs to be set if you use something like MMM-ProfileSwitcher and/or need to be able to load images from multiple Unsplash modules at once. | 'mmm-unsplash-placeholder' |
Here is an example of an entry in config.js
{
module: 'MMM-Unsplash',
position: 'fullscreen_below',
config: {
collections: '369966,1240111,1136512,629911,150672,920773',
apiKey: 'your_api_key'
}
},
Notes
Pull requests are very welcome! If you'd like to see any additional functionality, don't hesitate to let me know.
Dependencies
None!
Special Thanks
MMM-RandomPhoto for the inspiration. The core image update functionality is cribbed from this module.