Forum Thread
Automatic hyperlinks
Forum-Index → Suggestions → Automatic hyperlinksThis will make sharing links easier in general but especially for people who don't know about BBcode yet and perhaps for mobile users.
A link such as https://google.com would be changed into google.com while
[url=https://google.com]a useful site[/url] would be a useful site as you'd expect.
If you don't include the http(s):// it won't change into a link.
Implementation (For Riako)
In PHP before inserting into database: (The random links in $text are to test different scenarios)
$text = "https://google.com?test Use
[url=https://google.com/]google[/url] if youhttps://google.com/
don't https://google.com/ know it. https://google.com/ \ n
https://google.com/";
$url_pattern = "/([^=\]\w]|^)(https?:\/\/([\w|\.]+)([\/|\?]\S*)?)(\s?)/m";
$url_replace = "$1[url=$2]$3[/url]$5";
$text = preg_replace($url_pattern, $url_replace, $text);
$url_pattern = "/([^=\]\w]|^)(https?:\/\/([\w|\.]+)([\/|\?]\S*)?)(\s?)/m";
$url_replace = "$1[url=$2]$3[/url]$5";
$text = preg_replace($url_pattern, $url_replace, $text);
Result:
[url=https://google.com?test]google.com[/url] Use
[url=https://google.com/]google[/url] if youhttps://google.com/
don't [url=https://google.com/test?test]google.com[/url] know it.
[url=https://google.com/]google.com[/url]
[url=https://google.com/]google.com[/url]
[url=https://google.com/]google.com[/url]
which is equal to the following in feeds / palpad
google.com Use google if youhttps://google.com/ don't google.com know it. google.com
google.com
So all links without BBcode are changed into links except the one where there's no space between "you" and the link (this can easily be changed if desirable).
The link with BBcode was untouched, if someone writes [img]https://example.com/img.png[/img] the link will also not change.
Show
hidden content
https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/e95f5a57-899e-4c5b-b1fa-833423838322/de3leep-7ac3dbed-b547-4ee1-a1df-348c741b8644.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOiIsImlzcyI6InVybjphcHA6Iiwib2JqIjpbW3sicGF0aCI6IlwvZlwvZTk1ZjVhNTctODk5ZS00YzViLWIxZmEtODMzNDIzODM4MzIyXC9kZTNsZWVwLTdhYzNkYmVkLWI1NDctNGVlMS1hMWRmLTM0OGM3NDFiODY0NC5wbmcifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6ZmlsZS5kb3dubG9hZCJdfQ.PrSYOTlAGHGIHHJdKxrKuKpYiuhDfAaIoVPk8r8b0jA
the only way i would see around this is if the links are automatically shortened (not sure if you mentioned that n i just missed it lol)
typing [img] and [url=] only takes a few extra seconds, so i don't really see a necessity for this. i wont vote against it tho...just not voting on it for now