GithubHelp home page GithubHelp logo

rexblack / jquery-imageformat Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 492 KB

This plugin let's you dynamically assign different formats to lazy loaded images dependent on screen resolution

JavaScript 100.00%

jquery-imageformat's Introduction

jquery-imageformat

This plugin let's you dynamically assign different urls to lazy loaded images dependent on screen resolution

Basic Usage

Define image-urls for different formats:

<img class="lazy" 
  data-src-large="images/1200px-ESO-VLT-Laser-phot-33a-07.jpg"
  data-src-medium="images/640px-ESO-VLT-Laser-phot-33a-07.jpg" 
  data-src-small="images/218px-ESO-VLT-Laser-phot-33a-07.jpg"/>

You may choose from the following predefined resolutions:

small medium large big
320x520 768x1024 1680x1050 1920x1050

Call the plugin-method on the element:

$(function() {
  $('img.lazy').imageformat();
});

By default, the client format's url is copied to the src-attribute which will start loading the image. Read ahead to find out, how to use a different attribute and integrate with jquery-lazyload.

Advanced Usage

Using a custom attribute

$(function() {
  $('img.lazy').imageformat({
    attribute: 'data-original'
  }).lazyload();
});

Register a custom format

$.fn.imageformat.setImageFormat('my-format', 1280, 990);

Options

options.attribute

Type: String Default value: src

Name of the attribute the client format's corresponding url is copied to. Defaults to src.

jquery-imageformat's People

Contributors

rexblack avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.