Skip to content

Instantly share code, notes, and snippets.

@Guley
Created February 24, 2020 05:08
Show Gist options
  • Save Guley/615a29a9b85e02eddb4d140ecbc9ed0e to your computer and use it in GitHub Desktop.
Save Guley/615a29a9b85e02eddb4d140ecbc9ed0e to your computer and use it in GitHub Desktop.
<script>
var imagesRef = document.getElementsByTagName('img');
for(var i = 0; i < imagesRef.length; i++) {
var filename = imagesRef[i].src;
var oldAlt = imagesRef[i].alt;
if(oldAlt != null){
var newRa = filename.substring(0, filename.lastIndexOf('.'));
var imgObj = newRa.split("/");
imagesRef[i].alt = imgObj.slice(-1);
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment