jquery-bg-unsplash

1.0.1 • Public • Published

jquery-bg-unsplash

jQuery plugin to change a full background image from Unsplash

Installation

npm install jquery-bg-unsplash
You need to load jQuery first
<script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="/node_modules/jquery-bg-unsplash/src/index.js"></script>

Before using the Unsplash API, you need to register as developer then you must put the CLIENT_ID to be enable to get photos from Unsplash API.

window.BgUnsplash.setup(clientId);

How it works?

<div id="bg-unsplash"></div>
$(document).ready(function() {
    window.BgUnsplash.setup(clientId);
    $('#bg-unsplash').bgUnsplash({
     minHeight: '700px', // by default it's 800px
        backgroundSize: 'contain', // by default it's cover
        backgroundPosition: 'top center', // by default it's center
        backgroundColor: 'red', // by default it's black
    });
});

Package Sidebar

Install

npm i jquery-bg-unsplash

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • ezavile