<commit_before>$(document).ready(function() {
    $( window ).resize(function() {
        resizeImages();
    });
    resizeImages();
});

function resizeImages() {
    $('#main-page img').each(function() {
        var imageHeight = this.naturalHeight;
        var imageWidth = this.naturalWidth;
        var divHeight = parseInt($(this).closest('div').css('height'));
        var divWidth = parseInt($(this).closest('div').css('width'));
        if (imageHeight/imageWidth < divHeight/divWidth) { // Querformat
            if (imageHeight > divHeight) {
                $(this).css('height', divHeight + 'px');
                $(this).css('width', '');
            }
        } else { // Hochformat
            if (imageWidth > divWidth) {
                $(this).css('width', divWidth + 'px');
                $(this).css('height', '');
            }
        }

    });
}<commit_msg>issue #4, Bildskalierung funktioniert nun auch zuverlässig bei onload<commit_after>$(document).ready(function() {
    $( window ).resize(function() {
        resizeImages();
    });
    $("img").one("load", function() {
        resizeImage(this);
    }).each(function() {
        if(this.complete) $(this).load();
    });
});

function resizeImages() {
    $('#main-page img').each(function() {
        resizeImage(this);

    });
}

function resizeImage(imageElement) {
    var imageHeight = imageElement.naturalHeight;
    var imageWidth = imageElement.naturalWidth;
    var divHeight = parseInt($(imageElement).closest('div').css('height'));
    var divWidth = parseInt($(imageElement).closest('div').css('width'));
    if (imageHeight/imageWidth < divHeight/divWidth) { // Querformat
        if (imageHeight > divHeight) {
            $(imageElement).css('height', divHeight + 'px');
            $(imageElement).css('width', '');
        }
    } else { // Hochformat
        if (imageWidth > divWidth) {
            $(imageElement).css('width', divWidth + 'px');
            $(imageElement).css('height', '');
        }
    }
}
{'fraction_non_alphanumeric': 0.1826302729528536, 'fraction_numerical': 0.0004962779156327543, 'mean_word_length': 2.506086956521739, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1364903', 'n_tokens_mistral': 581, 'n_tokens_neox': 575, 'n_words': 98}