michaeldank
9/11/2017 - 12:26 AM

This will take background-images in the #outerSidebar and turn them into <img> tag - good for responsive upgrades when you don't want to cro

This will take background-images in the #outerSidebar and turn them into tag - good for responsive upgrades when you don't want to crop the image

<script>

$("#outerSidebar .item").each(function(){   
    
    //GET BACKGROUND IMG URL
    var bg = $(this).find(".contentImg").css('background-image');
    bg = bg.replace('url(','').replace(')','');
    bg = bg.replace("\"", '');
    bg = bg.replace("\"", '');
    //CREATE IMAGE
    var img = "<img src='" + bg + "'/>";
    //INSERT IMAGE
    $(this).find(".overlayImg").html(img);
    
});

</script>