The following script works but not as expected.
<img class="img" src="https://photoooo.com/Name-Name2.jpg" width="200" height="300" />
$(document).ready(function() {
$('img').each(function(){
var $img = $(this);
var filename = $img.attr('src')
if (typeof attr == typeof undefined || attr == false){
$img.attr('alt', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
}
});
});
I would like to modify the script so that it fetches the name of the photo to "alt" from the url of the photo. Excluding characters: "-" and ".jpg".