From 37bd03422bf74bd7fe8213fa519c3eb3efd83af5 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 4 Dec 2015 06:50:23 +0100 Subject: [PATCH] The preview picture can now be remote or local --- include/ostatus.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/include/ostatus.php b/include/ostatus.php index 01f6873aa8..593a9232a4 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -9,6 +9,7 @@ require_once("include/socgraph.php"); require_once("include/Photo.php"); require_once("include/Scrape.php"); require_once("include/follow.php"); +require_once("mod/proxy.php"); define('OSTATUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes define('OSTATUS_DEFAULT_POLL_TIMEFRAME', 1440); // given in minutes @@ -1092,9 +1093,25 @@ function xml_add_element($doc, $parent, $element, $value = "", $attributes = arr function ostatus_format_picture_post($body) { $siteinfo = get_attached_data($body); - if (($siteinfo["type"] == "photo") AND isset($siteinfo["url"]) AND isset($siteinfo["preview"])) { - $siteinfo["preview"] = str_replace(array("-1.jpg", "-1.png"), array("-2.jpg", "-2.png"), $siteinfo["preview"]); - $body = trim($siteinfo["text"])." [url]".$siteinfo["url"]."[/url]\n[img]".$siteinfo["preview"]."[/img]"; + if (($siteinfo["type"] == "photo")) { + if (isset($siteinfo["preview"])) + $preview = $siteinfo["preview"]; + else + $preview = $siteinfo["image"]; + + // Is it a remote picture? Then make a smaller preview here + $preview = proxy_url($preview, false, PROXY_SIZE_SMALL); + + // Is it a local picture? Then make it smaller here + $preview = str_replace(array("-0.jpg", "-0.png"), array("-2.jpg", "-2.png"), $preview); + $preview = str_replace(array("-1.jpg", "-1.png"), array("-2.jpg", "-2.png"), $preview); + + if (isset($siteinfo["url"])) + $url = $siteinfo["url"]; + else + $url = $siteinfo["image"]; + + $body = trim($siteinfo["text"])." [url]".$url."[/url]\n[img]".$preview."[/img]"; } return $body;