Im having trouble with the Slick carousel JS plugin with multiple slidesToShow which have different heights.
I need the Slides to have the same
I've wrote a quick JS hack to make a gallery with different images heights to look a little neater.
It does the following:
Set src attr to image's parent as a background image together with some CSS.
function equalizeImagesHeight(slider) {
const slides = slider.find('.slick-slide');
const imgHeight = $(slider)[0].clientHeight;
slides.each(function(slide){
const src = $(this).find('img').hide().attr('src');
$(this).css({
backgroundImage:'url('+src+')',
minHeight: imgHeight,
backgroundSize: "cover",
backgroundPosition: "center"
});
});
};
equalizeImagesHeight($('.my-slider'));