Skip to content

Instantly share code, notes, and snippets.

@mvargasmoran
Created August 29, 2014 19:28
Show Gist options
  • Save mvargasmoran/2ada12522e8a02d3816d to your computer and use it in GitHub Desktop.
Save mvargasmoran/2ada12522e8a02d3816d to your computer and use it in GitHub Desktop.
<!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>
$(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