Created
January 3, 2016 06:43
-
-
Save Drnutsu/a59c251d9228e5dbbc00 to your computer and use it in GitHub Desktop.
check portrait script for outsource image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get outsource images dimension | |
function getMeta(url, img_obj, cb){ | |
var img = new Image(); | |
img.onload = function(){ | |
if(cb)cb(img.height, img_obj, img.width); | |
}; | |
img.src = url; | |
} | |
// crop portrait image | |
var star_img = $(".star-img"); | |
star_img.each(function() { | |
console.log($(this)); | |
var prop = getMeta($(this).attr("src"), $(this), function(w, img_obj, h){ | |
if ( w > h){ | |
img_obj.addClass('portrait'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment