I have this code that automatically loads another image from the array every time the user loads index.html. This is the jquery code:
$(window).load(function() {
var randomImages = ['img1','img2','img3','img4','img5'];
var rndNum = Math.floor(Math.random() * randomImages.length);
var $win = $(this);
var $img = $('#background').attr('src', '_img/bg/index_rnd/' + randomImages[rndNum] + '.jpg').css({'position':'fixed','top':0,'left':0});
function resize() {
if (($win.width() / $win.height()) < ($img.width() / $img.height())) {
$img.css({'height':'100%','width':'auto'});
} else {
$img.css({'width':'100%','height':'auto'});
}
}
$win.resize(function() { resize(); }).trigger('resize');
});
I am new to adapting images to various screen resolutions. Therefore, I thought that if someone opens my website, for example, with imac with 2560 / 1440px, the image will be correctly adapted with this code, but I believe that it will be completely pixelated. Therefore, I think that I need to create a larger file so that these computers download a larger file for adaptation in resolution. I want other users with a normal screen to upload a large file for speed reasons. What can I add to this code to make large screens load a larger file so that it does not display pixels?!?!
PD If you also know what the best image resolution for different groups of screen sizes would be very useful!
Thank!