Code Monkey home page Code Monkey logo

loremimages's Introduction

LoremImages

LoremImages is a jQuery plugin for populating your content with random images. Images are loaded from LoremPixel service and licensed under the Creative Commons Attribution-ShareAlike license.

See the DEMO

Usage

$("#container").loremImages( width, height [, options ] );

Arguments

width Width of all images [int]

height Height of all images [int]

options Optional plugin options [obj]. Options list:

  • count [int] number of images that should be loaded, default is 10
  • grey [bool] whether to load only black & white images, default is false
  • randomWidth [int] random range for width value, default is 0
  • randomHeight [int] random range for height value, default is 0
  • category [string] images category, defaul is all categories. can be: abstract, animals, city, food, nightlife, fashion, people, nature, sports, technics, transport
  • itemBuilder [function] function that returns HTML for one item. function arguments are: index, url, imgWidth, imgHeight. default output is <img src="[url]" alt="Lorempixel">
randomWidth & randomHeight options

With these two options you can randomize sizes of final images. For example, if width is 100 and options.randomWidth is 200, it will generate images from 100 to 300 pixels wide.

Examples

Call with all options

$("ul.images").loremImages( 100, 200, { // images base size 100 x 200 pixels
    count:        20,        // load 20 images
    grey:         1,         // load grey / black & white images
    randomWidth:  100,       // width will be in 100-200 range
    randomHeight: 100,       // height will be in 200-300 range
    category:     'fashion', // get images from fashion category
    itemBuilder:  function( index, url, width, height ){ // custom HTML output for UL container
        // `this` is jQuery wrapped container element
        return '<li><img src="'+url+'" width="'+width+'" height="'+height+'" alt="Image '+(i+1)+'"></li>';
    }
});

loremimages's People

Contributors

darsain avatar

Watchers

James Cloos avatar Tom Keen avatar

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.