var limitImagesPreview = function(selector) {
const max_height = 200;
var limited_image = '<div class="limited-parent-image"></div>';
var limited_description = '<span class="limited-expand">'+
'<i class="glyphicon glyphicon-resize-full"></i>'+
'</span>';
var limited_modal = '<div class="limited-modal">'+
' <span class="limited-close-modal">×</span>'+
' <img class="limited-modal-content-image">'+
'</div>';
$(selector).each(function(i, block){
var images = $(block).find('img');
for (var i = 0; i < images.length; i++) {
var image = $(images[i]);
image.addClass('limited-origin-image');
if ((image.height() > max_height) ||
(image.get(0).height > max_height) ||
(image.get(0).naturalHeight > max_height)) {
image.wrap(limited_image);
image.closest('.limited-parent-image').append(limited_description);
image.closest('.limited-parent-image').after(limited_modal);
}else {
image.load(function(){
if(this.height > max_height) {
image.wrap(limited_image);
image.closest('.limited-parent-image').append(limited_description);
image.closest('.limited-parent-image').after(limited_modal);
}
});
}
}
});
};
$(document).on('click', '.limited-parent-image', function() {