Code Monkey home page Code Monkey logo

minigram's Introduction

Minigram

A simple plugin to display your latest Instagram photos with Vanilla JS

Demo

View demo here

Install

With npm

npm install minigram --save

Download

You can download the latest version or checkout all the releases here.

How to use?

Require the package or use the global Minigram namespace:

AMD

<script>
require(["path/to/minigram.js"], function(Minigram) {
    // Code here
});
</script>

commonJS

var Minigram = require('Minigram');

ES6

import Minigram from 'Minigram';

Browser

<script src="path/to/minigram.js"></script>

Basic Usage

See how easy it is to obtain images of a profile:

<script>
    new Minigram(target, {
        counter: 8,
        resolution: 'low',
        token: 'YOUR_TOKEN_HERE',
        html: '<li class="instagram-thumbnail"><a class="instagram-placeholder" href="{url}" target="_blank"><img src="{image}" alt="{caption}"></a></li>'
    });
</script>

Requirements

The only thing you'll need to get going is a valid access token from Instagram's API. You can easily register for one on Instagram's website.

Options

  • target - Either the ID name, CLASS name or the DOM element itself where you want to add the images to.
  • counter - Maximum number of images to display. Default is 10. Max of 20
  • resolution - Size of the images to get. Available options are:
    • thumb (default) - 150x150
    • low - 306x306
    • standard - 612x612
  • token - A valid oAuth token. See the wiki how to get your token
  • html - Custom HTML template to use for images. See templating.
  • before (function) - A callback function called before fetching images from Instagram.
  • after (function) - A callback function called when Instagram returns valid data.
  • error (function) - A callback function called if the API Instagram return error (argument -> json object).
  • success (function) - A callback function called when images have been added to the page.

Templating

The easiest way to control the way minigram.js looks on your website is to use the template option. You can write your own HTML markup and it will be used for every image that minigram.js fetches.

Here's a quick example:

<script>
    new Minigram(target, {
        counter: 8,
        resolution: 'low',
        token: 'YOUR_TOKEN_HERE',
        html: '<a href="{url}"><img src="{image}" alt="{caption}"></a>'
    });
</script>

Notice the {url}, {image} and {caption}? The templating option provides several tags for you to use to control where variables are inserted into your HTML markup. Available keywors are:

  • {caption} - Image's caption text. Defaults to empty string if there isn't one.
  • {url} - URL to view the image on Instagram's website.
  • {type} - the image's type. Can be image or video.
  • {likes} - Number of likes the image has.
  • {filter} - Filter name used in photo.
  • {image} - URL of the image source. The size is inherited from the resolution option.

Browser Support

IE Chrome Firefox Opera Safari
IE 9+ โœ” Latest โœ” Latest โœ” Latest โœ” Latest โœ”

Contributing

Check CONTRIBUTING.md for more information.

History

Check Releases for detailed changelog.

License

MIT

minigram's People

Contributors

pinceladasdaweb avatar

Stargazers

 avatar Mohammed Raji avatar Neuropass avatar Richard Saunders avatar WEBBAB avatar Hector Zarco  avatar Isac Fadoni avatar Paul Solbach avatar Breno Polanski avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

trashsydowdev

minigram's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.