Skip to content

Instantly share code, notes, and snippets.

@Drnutsu
Created January 3, 2016 06:43
Show Gist options
  • Save Drnutsu/a59c251d9228e5dbbc00 to your computer and use it in GitHub Desktop.
Save Drnutsu/a59c251d9228e5dbbc00 to your computer and use it in GitHub Desktop.
check portrait script for outsource image.
// 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