]> git.mxchange.org Git - friendica.git/commitdiff
Add missing provider url and name
authorMichael <heluecht@pirati.ca>
Sat, 1 May 2021 17:03:50 +0000 (17:03 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 1 May 2021 17:03:50 +0000 (17:03 +0000)
src/Model/Item.php

index 859deacc3ed33492c2b00e4177edb5dbbd53426c..13da8ec75b135e84f2d498fe67c00b0a21c550bf 100644 (file)
@@ -2889,6 +2889,20 @@ class Item
                DI::profiler()->saveTimestamp($stamp1, 'rendering');
 
                if (isset($data['url']) && !in_array($data['url'], $ignore_links)) {
+                       $parts = parse_url($data['url']);
+                       if (!empty($parts['scheme']) && !empty($parts['host'])) {
+                               if (empty($data['provider_name'])) {
+                                       $data['provider_name'] = $parts['host'];
+                               }
+                               if (empty($data['provider_url']) || empty(parse_url($data['provider_url'], PHP_URL_SCHEME))) {
+                                       $data['provider_url'] = $parts['scheme'] . '://' . $parts['host'];
+
+                                       if (!empty($parts['port'])) {
+                                               $data['provider_url'] .= ':' . $parts['port'];
+                                       }
+                               }
+                       }
+
                        // @todo Use a template
                        $rendered = BBCode::convertAttachment('', BBCode::INTERNAL, false, $data);
                        if ($shared) {