Code (Javascript) pasted on 2019-10-17, 21:06 Raw Source
- function fillSlides(slides) {
- let boxWidth, size, elem, elemActive;
- let activeSlide = $('.carousel-inner').find('.active');
- $.each(slides, function (slide, items) {
- $.each(items, function (item, itemValue) {
- elem = $('#' + slide).find('.' + item);
- boxWidth = activeSlide.find('.' + item).width();
- if (boxWidth >= 1152) {
- size = '1920w';
- } else if (boxWidth >= 768) {
- size = '1152w';
- } else if (boxWidth >= 384) {
- size = '768w';
- } else {
- size = '384w';
- }
- elem.css('background-image', 'url(' + itemValue + '&size=' + size + ')');
- console.log(slide + ' ' + item + ' ' + itemValue + '(' + size + ')');
- });
- });
- }