Skip to content

Instantly share code, notes, and snippets.

@ewebdev
Created March 6, 2014 15:35
Show Gist options
  • Save ewebdev/9392320 to your computer and use it in GitHub Desktop.
Save ewebdev/9392320 to your computer and use it in GitHub Desktop.
"use strict";
define([
'jquery',
'underscore'
], function ($, _) {
$.fn.loadImg = function (options) {
// var opts = $.extend({}, $.fn.loadImg.defaults, options);
return this.each(function () {
var $ph = $(this);
var $img = $('<img/>', {src: $ph.data('src'), class: $ph.data('img-class') || '', style: $ph.data('img-style') || {}}).load(function () {
var tagName = $ph.data('tag') || 'img',
$el = tagName === 'img' ? $img : $('<' + tagName + '/>', {class: $ph.data('img-class') || '', style: $ph.data('img-style') || {}});
$ph.append($el).addClass($ph.data('loaded-class') || '');
});
});
};
/* $.fn.loadImg.defaults = {
};*/
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment