]> git.mxchange.org Git - friendica.git/commitdiff
Update ParseUrl::getSiteinfo type recognition
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 2 Sep 2018 21:50:27 +0000 (17:50 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Sun, 2 Sep 2018 21:50:27 +0000 (17:50 -0400)
- Added obsolete twitter card type provision

src/Util/ParseUrl.php

index b897c54ee7dd58da0a94d3a9ce92aaccb8d4e5c8..2c134542a0392e279dd6f64f4008ec7cf8e52c74 100644 (file)
@@ -248,55 +248,61 @@ class ParseUrl
                                }
                        }
 
-                       if (!empty($meta_tag['content'])) {
-                               $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8'));
-
-                               switch (strtolower($meta_tag['name'])) {
-                                       case 'fulltitle':
-                                               $siteinfo['title'] = trim($meta_tag['content']);
-                                               break;
-                                       case 'description':
-                                               $siteinfo['text'] = trim($meta_tag['content']);
-                                               break;
-                                       case 'thumbnail':
-                                               $siteinfo['image'] = $meta_tag['content'];
-                                               break;
-                                       case 'twitter:image':
-                                               $siteinfo['image'] = $meta_tag['content'];
-                                               break;
-                                       case 'twitter:image:src':
-                                               $siteinfo['image'] = $meta_tag['content'];
-                                               break;
-                                       case 'twitter:card':
-                                               if (($siteinfo['type'] == '') || ($meta_tag['content'] == 'photo')) {
-                                                       $siteinfo['type'] = $meta_tag['content'];
-                                               }
-                                               break;
-                                       case 'twitter:description':
-                                               $siteinfo['text'] = trim($meta_tag['content']);
-                                               break;
-                                       case 'twitter:title':
-                                               $siteinfo['title'] = trim($meta_tag['content']);
-                                               break;
-                                       case 'dc.title':
-                                               $siteinfo['title'] = trim($meta_tag['content']);
-                                               break;
-                                       case 'dc.description':
-                                               $siteinfo['text'] = trim($meta_tag['content']);
-                                               break;
-                                       case 'keywords':
-                                               $keywords = explode(',', $meta_tag['content']);
-                                               break;
-                                       case 'news_keywords':
-                                               $keywords = explode(',', $meta_tag['content']);
-                                               break;
-                               }
+                       if (empty($meta_tag['content'])) {
+                               continue;
                        }
-                       if ($siteinfo['type'] == 'summary') {
-                               $siteinfo['type'] = 'link';
+
+                       $meta_tag['content'] = trim(html_entity_decode($meta_tag['content'], ENT_QUOTES, 'UTF-8'));
+
+                       switch (strtolower($meta_tag['name'])) {
+                               case 'fulltitle':
+                                       $siteinfo['title'] = trim($meta_tag['content']);
+                                       break;
+                               case 'description':
+                                       $siteinfo['text'] = trim($meta_tag['content']);
+                                       break;
+                               case 'thumbnail':
+                                       $siteinfo['image'] = $meta_tag['content'];
+                                       break;
+                               case 'twitter:image':
+                                       $siteinfo['image'] = $meta_tag['content'];
+                                       break;
+                               case 'twitter:image:src':
+                                       $siteinfo['image'] = $meta_tag['content'];
+                                       break;
+                               case 'twitter:card':
+                                       // Obsolete card type
+                                       if ($meta_tag['content'] == 'photo') {
+                                               $siteinfo['type'] = 'summary_large_image';
+                                       } else {
+                                               $siteinfo['type'] = $meta_tag['content'];
+                                       }
+                                       break;
+                               case 'twitter:description':
+                                       $siteinfo['text'] = trim($meta_tag['content']);
+                                       break;
+                               case 'twitter:title':
+                                       $siteinfo['title'] = trim($meta_tag['content']);
+                                       break;
+                               case 'dc.title':
+                                       $siteinfo['title'] = trim($meta_tag['content']);
+                                       break;
+                               case 'dc.description':
+                                       $siteinfo['text'] = trim($meta_tag['content']);
+                                       break;
+                               case 'keywords':
+                                       $keywords = explode(',', $meta_tag['content']);
+                                       break;
+                               case 'news_keywords':
+                                       $keywords = explode(',', $meta_tag['content']);
+                                       break;
                        }
                }
 
+               if ($siteinfo['type'] == 'summary' || $siteinfo['type'] == 'summary_large_image') {
+                       $siteinfo['type'] = 'link';
+               }
+
                if (isset($keywords)) {
                        $siteinfo['keywords'] = [];
                        foreach ($keywords as $keyword) {