JSFiddle - React, Tailwind, and code Playground

HTML

<img src="http://placehold.it/1950x550" class="imgresize">

CSS

body, html {margin:0; padding:0;}

JavaScript

var wWidth = $(window).width();
var wHeight = $(window).height();

$('.imgresize').each( function() {
var imgWidth = $(this).width();
var imgHeight = $(this).height();

    if(imgWidth >  wWidth)
    {
        $(this).width(wWidth);
    }

    if(imgHeight >  wHeight )
    {
        $(this).width(wHeight);
    }

});


$(window).resize(function() {
var wWidth = $(window).width();
var wHeight = $(window).height();

$('.imgresize').each( function() {
var imgWidth = $(this).width();
var imgHeight = $(this).height();

    if(imgWidth >  wWidth)
    {
        $(this).width(wWidth);
    }

    if(imgHeight >  wHeight )
    {
        $(this).width(wHeight);
    }

});

});