]> git.mxchange.org Git - friendica.git/blobdiff - include/ostatus.php
OStatus: Picture posts are reformatted
[friendica.git] / include / ostatus.php
index ebd5741e5157a44977a4f6452857c2f509199191..01f6873aa8b5da39148744383d8976ebc5287960 100644 (file)
@@ -1089,6 +1089,17 @@ function xml_add_element($doc, $parent, $element, $value = "", $attributes = arr
        $parent->appendChild($element);
 }
 
+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]";
+       }
+
+       return $body;
+}
+
 function ostatus_add_header($doc, $owner) {
        $a = get_app();
 
@@ -1332,6 +1343,8 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
        else
                $body = $item['body'];
 
+       $body = ostatus_format_picture_post($body);
+
        if ($item['title'] != "")
                $body = "[b]".$item['title']."[/b]\n\n".$body;