diff --git a/twemoji-generator.js b/twemoji-generator.js
index a0954a22..40df4400 100755
--- a/twemoji-generator.js
+++ b/twemoji-generator.js
@@ -642,6 +642,15 @@ function createTwemoji(re) {
img.onerror = twemoji.onerror;
img.className = options.className;
img.setAttribute('draggable', 'false');
+ var attrib = options.attributes;
+ if (typeof(attrib) === 'function') {
+ attrib = attrib(alt);
+ }
+ if (attrib) {
+ for (var attrname in attrib) {
+ img.setAttribute(attrname) = attrib[attrname];
+ }
+ }
img.alt = alt;
img.src = src;
}
@@ -694,6 +703,17 @@ function createTwemoji(re) {
if (src) {
// recycle the match string replacing the emoji
// with its image counter part
+ var attrib = options.attributes;
+ if (typeof(attrib) === 'function') {
+ attrib = attrib(match);
+ }
+ var attr_text = '';
+ if (attrib) {
+ for (var attrname in attrib) {
+ attr_text = attr_text + ' ' + attrname + '="' + attrib[attrname].replace(/"/g, '"') + '"';
+ }
+ }
+
match = '
")}}return match})}function toSizeSquaredAsset(value){return typeof value==="number"?value+"x"+value:value}function fromCodePoint(codepoint){var code=typeof codepoint==="string"?parseInt(codepoint,16):codepoint;if(code<65536){return fromCharCode(code)}code-=65536;return fromCharCode(55296+(code>>10),56320+(code&1023))}function parse(what,how){if(!how||typeof how==="function"){how={callback:how}}return(typeof what==="string"?parseString:parseNode)(what,{callback:how.callback||defaultImageSrcGenerator,base:typeof how.base==="string"?how.base:twemoji.base,ext:how.ext||twemoji.ext,size:how.folder||toSizeSquaredAsset(how.size||twemoji.size),className:how.className||twemoji.className})}function replace(text,callback){return String(text).replace(re,callback)}function test(text){re.lastIndex=0;var result=re.test(text);re.lastIndex=0;return result}function toCodePoint(unicodeSurrogates,sep){var r=[],c=0,p=0,i=0;while(i")}}return match})}function toSizeSquaredAsset(value){return typeof value==="number"?value+"x"+value:value}function fromCodePoint(codepoint){var code=typeof codepoint==="string"?parseInt(codepoint,16):codepoint;if(code<65536){return fromCharCode(code)}code-=65536;return fromCharCode(55296+(code>>10),56320+(code&1023))}function parse(what,how){if(!how||typeof how==="function"){how={callback:how}}return(typeof what==="string"?parseString:parseNode)(what,{callback:how.callback||defaultImageSrcGenerator,attributes:how.attributes,base:typeof how.base==="string"?how.base:twemoji.base,ext:how.ext||twemoji.ext,size:how.folder||toSizeSquaredAsset(how.size||twemoji.size),className:how.className||twemoji.className})}function replace(text,callback){return String(text).replace(re,callback)}function test(text){re.lastIndex=0;var result=re.test(text);re.lastIndex=0;return result}function toCodePoint(unicodeSurrogates,sep){var r=[],c=0,p=0,i=0;while(i