I know this question is extremely similar to one that has been asked before but it's not exactly the same and should not be treat as such (please mods/admins).
I'm currently using the Linkify() function that I found in a piece of code posted on here in another thread, however it does not contain a Regular Expression for Images. It only covers http, https and mailto but does not cover a link that may contain an image.
Basically what I'm asking, is there a regular expression that I can add to that function (there are already 3 patterns so one of images would be replacedPattern4) that would check for an image link only?
For example if in the text it finds a link like http://www.example.com/images/logo.jpg then it converts it to an image tag but obviously with the src="" containing that url. Reason I'm asking is for a chat project I'm working on I want to convert text links that are pointing to images to actual images just like Facebook does on the timeline.
Here is what I'm using and have added to the Linkify function as a fourth RegEx pattern:
replacePattern4 = /(\b(http):\/\/.(?:jpg|png|gif))</
replacedText = replacedText.replace(replacePattern4, '<img src="$1" height="100" width="100" />');
However this isn't working at all! Any ideas anyone??
Any help here would be great, please bare in mind the code the Linkify already uses.
Thanks!