Created
August 29, 2014 19:28
-
-
Save mvargasmoran/2ada12522e8a02d3816d to your computer and use it in GitHub Desktop.
// source http://jsbin.com/biyob/1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
$(document).ready(function(){ | |
function imgfy(text) { | |
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; | |
return text.replace(exp,"<a href='$1'> <img src='$1' /></a>"); | |
} | |
var message = 'checkout this url: http://1y4o79syc6g4difua2cvof9qco.wpengine.netdna-cdn.com/wp-content/uploads/2013/07/derp-284x300.png now that is a derp'; | |
var text = imgfy(message); | |
$('body').html(text); | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//code.jquery.com/jquery-2.1.1.min.js"><\/script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">$(document).ready(function(){ | |
function imgfy(text) { | |
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; | |
return text.replace(exp,"<a href='$1'> <img src='$1' /></a>"); | |
} | |
var message = 'checkout this url: http://1y4o79syc6g4difua2cvof9qco.wpengine.netdna-cdn.com/wp-content/uploads/2013/07/derp-284x300.png now that is a derp'; | |
var text = imgfy(message); | |
$('body').html(text); | |
});</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
function imgfy(text) { | |
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; | |
return text.replace(exp,"<a href='$1'> <img src='$1' /></a>"); | |
} | |
var message = 'checkout this url: http://1y4o79syc6g4difua2cvof9qco.wpengine.netdna-cdn.com/wp-content/uploads/2013/07/derp-284x300.png now that is a derp'; | |
var text = imgfy(message); | |
$('body').html(text); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment