]> git.mxchange.org Git - friendica.git/commitdiff
Generate preview pictures from enclosed data from feeds.
authorMichael Vogel <icarus@dabo.de>
Wed, 17 Dec 2014 20:57:38 +0000 (21:57 +0100)
committerMichael Vogel <icarus@dabo.de>
Wed, 17 Dec 2014 20:57:38 +0000 (21:57 +0100)
include/items.php

index 0398f545884eef878a0ce27b687bef74d4d69bab..bd1f48c5e3ba216b443faf168463a036229b7817 100644 (file)
@@ -872,9 +872,18 @@ function get_atom_elements($feed, $item, $contact = array()) {
        }
 
        if (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND $contact['fetch_further_information']) {
-               $res["body"] = $res["title"].add_page_info($res['plink'], false, "", ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
+               $preview = "";
+
+               // Handle enclosures and treat them as preview picture
+               if (isset($attach))
+                       foreach ($attach AS $attachment)
+                               if ($attachment->type == "image/jpeg")
+                                       $preview = $attachment->link;
+
+               $res["body"] = $res["title"].add_page_info($res['plink'], false, $preview, ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_blacklist']);
                $res["title"] = "";
                $res["object-type"] = ACTIVITY_OBJ_BOOKMARK;
+               unset($res["attach"]);
        } elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_OSTATUS))
                $res["body"] = add_page_info_to_body($res["body"]);
        elseif (isset($contact["network"]) AND ($contact["network"] == NETWORK_FEED) AND strstr($res['plink'], ".app.net/")) {
@@ -941,6 +950,9 @@ function add_page_info($url, $no_photos = false, $photo = "", $keywords = false,
 
        $data = parseurl_getsiteinfo($url, true);
 
+       if ($photo != "")
+               $data["images"][0]["src"] = $photo;
+
        logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
 
        if (!$keywords AND isset($data["keywords"]))