I'm appending a large image when it's done loading and fading it in which all works well. My problem is when there is more than one image. Then it's only the last small image that get replaced (with the first image). I can't seem to figure out how to separate them. The src URLs are retrieved trough a data-attribute. Codepen with two images. (with one image it works as intended).
window.onload = function() {
  var ImageBlur = function (element) {
    var self = this;
    this.element = element;
    this.$element = $(element); 
  };
  var placeholder = $('.js-image-blur', this.$element);
  var small = $('.js-small-image', placeholder);
  // Load large image
  var imgLarge = new Image();
  imgLarge.src = placeholder.data('largeimage');
  imgLarge.className = "is-large-image";
  imgLarge.onload = function () {
    $(imgLarge).addClass('is-loaded');
    // Remove small image
    setTimeout(function(){
      $(small).remove();
    }, 1200);
  };
  $(imgLarge).each(function() {
    placeholder.append(this);
  });
  return ImageBlur;
};
 
     
    