Removing small images
<p>I have following script to remove images that are too small but it doesn't work properly, first time I load the page, every image gets replaced with <code>no-image.png</code>, after I refresh page it works properly, what am I missing here?</p>

<pre><code>$(document).ready(function () {
    $('.story-img').error(function () {
        $(this).attr("src", "/Images/no-image.png");
        $(this).css('border', 'none');
    });

    $(".story-img").each(function () {

        var theImage = new Image();
        theImage.src = $(this).attr("src") || $(this).src;

        var imageWidth = theImage.width;
        var imageHeight = theImage.height;

        if (imageWidth &lt; 32 || imageHeight &lt; 32 || $(this).height() &lt; 32 || $(this).width &lt; 32) {
            $(this).attr("src", "/Images/no-image.png");
            $(this).css('border', 'none');
        }

    });
});
</code></pre>
