From: Michael Vogel Date: Wed, 17 Dec 2014 20:57:38 +0000 (+0100) Subject: Generate preview pictures from enclosed data from feeds. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=15f43d8ca3be780e6ee7117696acaa7e198a096a;p=friendica.git Generate preview pictures from enclosed data from feeds. --- diff --git a/include/items.php b/include/items.php index 0398f54588..bd1f48c5e3 100644 --- a/include/items.php +++ b/include/items.php @@ -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"]))