Code (Javascript) pasted on 2019-10-17, 20:18 Raw Source
- let slides = {
- 'slide1': {
- 'item34': 'https://photos.jeanbruenn.info/photo.php?path=di/2019/09/01/darktable_exported/_DSC4203.jpg',
- 'item21': 'https://photos.jeanbruenn.info/photo.php?path=lgis/2018/09/12/darktable_exported/DSC00348.jpg',
- 'item13': 'https://photos.jeanbruenn.info/photo.php?path=lgis/2019/09/07/darktable_exported/_DSC4440.jpg',
- 'item8': 'https://photos.jeanbruenn.info/photo.php?path=lgis/2019/07/21/darktable_exported/_DSC3731-hdr.jpg',
- 'item5': 'https://photos.jeanbruenn.info/photo.php?path=di/2019/09/01/darktable_exported/_DSC4267.jpg',
- 'item3': 'https://photos.jeanbruenn.info/photo.php?path=di/2019/09/01/darktable_exported/_DSC4186.jpg',
- 'item2': 'https://photos.jeanbruenn.info/photo.php?path=di/2019/09/01/darktable_exported/_DSC4231-hdr.jpg',
- 'item1': 'https://photos.jeanbruenn.info/photo.php?path=lgis/2019/02/17/darktable_exported/_DSC1491.jpg'
- }
- };
- let size, elem, boxWidth, boxHeight;
- $.each(slides, function (slide, items) {
- $.each(items, function (item, itemValue) {
- elem = $('#' + slide).find('.' + item);
- boxWidth = elem.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 + ')');
- });
- });