1.1.7 • Published 5 years ago
random-image-js v1.1.7
Random Image JS
A javascript package for fetching random memes and wallpapers. Fetched images are scraped from reddit.
Features:
- Bulk memes
- Bulk wallpapers
- Customizable
- Lightweight
PHP package is available at Packagist.
Installation
Install via NPM
npm install --save random-image-js
Usage
Available functions:
- getMemes()
- getWallpapers()
import randomImageJs from 'random-image-js';
#or
var randomImageJs = require('random-image-js');
-------------------
-------------------
//use with await
await randomImageJs.getMemes(); //returns 1 meme
await randomImageJs.getWallpapers(); //returns 1 wallpaper
//use with callback
randomImageJs.getMemes().then(response => {}); //returns 1 meme
randomImageJs.getWallpapers().then(response => {});//returns 1 wallpaper
//options
await randomImageJs.getWallpapers({ get: 50 }); //returns 50 wallpapers
await randomImageJs.getMemes({
get: 50,
addSubReddit: ['memes', 'funny'],
removeSubReddit: ['dankmemes']
}); //returns 50 memes by filtering
//can be use other than fetching memes and wallpapers
//use as cat image fetcher
await randomImageJs.getMemes({
get: 50,
removeAllSubReddit: true,
addSubReddit: ['cats', 'Catswhoyell', 'sleepingcats']
}); //returns 50 cat images
Result
The functions are asynchronous functions and return array.
[
{
id: "hfh51v",
title: "Illuminated City at Night [1920 x 1200]",
postLink: "https://redd.it/hfh51v",
image: "https://i.redd.it/b6x9i2n830751.jpg",
thumbnail: "https://b.thumbs.redditmedia.com/mLCk8Bh0N4M8hZafHsbAmw8rM7JEEznsT2nRZSo3GsU.jpg",
subreddit: "wallpaper",
NSFW: false,
spoiler: false,
createdUtc: 1593066557,
},
{
id: "h9glhi",
title: "Missing Home by Just Jaker",
postLink: "https://redd.it/h9glhi",
image: "https://cdnb.artstation.com/p/assets/images/images/027/020/665/large/just-jaker-galax-noise.jpg",
thumbnail: "https://b.thumbs.redditmedia.com/4utBLNbsIDDLl46z494PCRkDhmAnapQq9FL7l-07aJo.jpg",
subreddit: "ImaginaryFuturism",
NSFW: false,
spoiler: false,
createdUtc: 1592228591
}
]
Options
Browser Compatibility
Browser | Works? |
---|---|
Chrome | ✔ |
Firefox | ✔ |
Safari | ✔ |
IE 11 | ✔ |
Demo
Support
Support us by :star: on Github