Force set width and height to all image tags.
  • JavaScript 83.3%
  • HTML 16.7%
Find a file
2015-03-08 09:59:09 +09:00
example.html first commit 2015-03-08 09:25:04 +09:00
jquery.image-size-assign.js Remove debug code 2015-03-08 09:55:56 +09:00
README.md Modify sample code 2015-03-08 09:59:09 +09:00

jquery.image-size-assign.js

jQuery plugin to force set img size attribute(width, height).

<!-- before -->
<img src="http://placehold.it/350x150">

<!-- after -->
<img src="http://placehold.it/350x150" width="350" height="150">

How to use

$(function(){
  $("img").imageSizeAssign({
    maxSize:{
      width:500,
      height:500
    },
    onSize:function(size){
      return size;
    },
    onComplete:function(){
      //console.log("all sizes are set");
    }
  });
});

Option

maxSize

If defined, each size is rounded by maxSize if overflow, keeping original rate of size.

onSize

Callback function after each size is obtained and rounded.

onComplete

Callback function after all sizes are set.

License

MIT