출처 : http://jsfiddle.net/codingdude/V4xuq/


이메일을 통한 프로필 이미지 로딩 => 간단한 커뮤니티를 만들 때 사용하면 좋을거 같음.



<!-- modify the email attribute here then Run to see the gravatar image change -->

<codingdude-gravatar email="imtough99@gmail.com"></codingdude-gravatar>



var tagname = "codingdude-gravatar";

        document.createElement(tagname);

//find all the tags occurrences (instances) in the document

var tagInstances = document.getElementsByTagName(tagname);


//for each occurrence run the associated function

for ( var i = 0; i < tagInstances.length; i++) {

  codingdudeGravatar(tagInstances[i]);

}

function codingdudeGravatar(element){


//code for rendering the element goes here

if (element.attributes.email){


//get the email address from the element's email attribute

var email = element.attributes.email.value;

var gravatar = "http://www.gravatar.com/avatar/"+md5(email)+".png";

element.innerHTML = "<img src='"+gravatar+"'>";

}

}


    


+ Recent posts