1var cropSlickImages = function () { 2 3 var galleries = document.querySelectorAll('.my-gallery'); 4 for (var i = 0, l = galleries.length; i < l; i++) { 5 var gallery = galleries[i]; 6 var figures = gallery.getElementsByTagName('figure'); 7 for (var j = 0, m = figures.length; j < m; j++) { 8 9 var figure = figures[j]; 10 var figureWidth = getComputedDimension(figure, "width"); 11 var figureHeight = getComputedDimension(figure, "height"); 12 13 var imageDimension = figure.getElementsByTagName('a')[0].getAttribute('data-size'); 14 15 // console.log(imageDimension); 16 17 var imageWidth = Number(imageDimension.split('x')[0]); 18 var imageHeight = Number(imageDimension.split('x')[1]); 19 20 // console.log('Look Up'); 21 22 var image = figure.getElementsByTagName('img')[0]; 23 24 if (imageWidth / imageHeight == 1) { 25 //slick macht das schon 26 } 27 if (imageWidth < imageHeight) { //portrait 28 // console.log('portrait'); 29 var thumbHeight = (figureWidth / imageWidth) * imageHeight; 30 31 image.style.width = figureWidth.toString() + 'px'; 32 image.style.height = thumbHeight.toString() + 'px'; 33 34 var margin = (thumbHeight - figureHeight) / 2; 35 36 image.style.marginTop = "-" + margin.toString() + 'px'; 37 38 39 } 40 if (imageWidth > imageHeight) { // landscape 41 // console.log('landscape'); 42 var thumbWidth = (figureHeight / imageHeight) * imageWidth; 43 44 image.style.height = figureHeight.toString() + 'px'; 45 image.style.minWidth = thumbWidth.toString() + 'px'; 46 47 var margin = (thumbWidth - figureWidth) / 2; 48 49 image.style.marginLeft = "-" + margin.toString() + "px"; 50 } 51 } 52 } 53 54 55 function getComputedDimension(tag, dimension) { 56 var dimension = Number(window.getComputedStyle(tag, null).getPropertyValue(dimension).slice(0, -2)); 57 return dimension; 58 } 59 60}; 61 62jQuery(document).ready(function () { 63 cropSlickImages(); 64}); 65 66/*jQuery(window).bind('resize', function() { 67 cropSlickImages(); 68});*/ 69
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.