Help with the code

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>

The var imRegExpUrl line looks to be invalid.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.