Skip to content

Instantly share code, notes, and snippets.

@seleckis
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seleckis/e669f76f3fa80b565f49 to your computer and use it in GitHub Desktop.
Save seleckis/e669f76f3fa80b565f49 to your computer and use it in GitHub Desktop.
String method to return retina filenames
String.prototype.retina = function () {
return this.replace(/(\.\w+$)/, "@2x$1");
};
<!DOCTYPE html>
<html>
<head>
<title>String Prototype Retina</title>
<script src="String.prototype.retina.js" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript">
var filename = "logo.png";
document.write(filename.retina());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment