I need help with this code, it supposed to turn img links into embeds but it doesn’t work
<script>
$(document).ready(function(){
var imRegExpUrl = (http(s?):)|([/|.|\w|\s])*\.(?:jpg|gif|png);
var imFrame = '<img src="' + $(this).attr('href') + '" />'`
` function replaceUrlToEmbed() {
$("#content-content a").each(function() {
var toText = $(this).attr('href');
}
var replacement = imFrame.replace('$(this).attr('href')', textToReplace);
$(this).replaceWith(replacement);
}
}
});
};`
` Drupal.behaviors.imUrlToEmbedBehaviour = function(context, settings) {`
` $(document).ajaxComplete(function(event, xhr, settings) {
replaceUrlToEmbed();
});
}
});
</script>