autoimgsizes (中文)
Base on qiniu cdn, use API of qiniu to show image the best size on container.
bower install autoimgsizes
import autoimgsizes.min.js
-
requirejs
require(["./autoimgsizes"],function(){ })
-
script
<script type="text/javascript" src="autoimgsizes.js"></script>
Then on img
add class
:autoImgSizes
, data-src
: url of image on qiniu, data-origin-size
:image size widthxheight
-
Size of parent
<div> <img class="autoImgSizes" src="" data-src="http://xxxxxx.png" data-origin-size="300x300"/> </div>
-
Scale by image size
<div> <img class="autoImgSizes" src="" data-src="http://xxxxxx.png" data-origin-size="300x300" data-auto="auto"/> </div>
autoImgSizeConfig:
srcAttr
value:data-src
autoAttr
value:data-auto
originSizeAttr
valuedata-origin-size
autoImgClass
valueautoImgSizes
Want to redefine the attribute value,for change autoImgSizes
to imgSizes
, just like blow:
<script type="text/javascript">
window.autoImgSizeConfig = window.autoImgSizeConfig || {};
window.autoImgSizeConfig.autoImgClass = "imgSizes";
</script>