Merge branch '1512-ostatus-picture-posts' of github.com:annando/friendica into 1512-ostatus-picture-posts

This commit is contained in:
Michael Vogel 2015-12-04 06:00:56 +01:00
commit f82ce0de66
3 changed files with 18 additions and 4 deletions

View file

@ -959,14 +959,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text); $Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text);
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
if ($simplehtml != 7) { // if ($simplehtml != 7) {
if (!$forplaintext) if (!$forplaintext)
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text); $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
else { else {
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text); $Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text); $Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
} }
} // }
if ($tryoembed) if ($tryoembed)
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text); $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text);

View file

@ -1089,6 +1089,17 @@ function xml_add_element($doc, $parent, $element, $value = "", $attributes = arr
$parent->appendChild($element); $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) { function ostatus_add_header($doc, $owner) {
$a = get_app(); $a = get_app();
@ -1332,6 +1343,8 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
else else
$body = $item['body']; $body = $item['body'];
$body = ostatus_format_picture_post($body);
if ($item['title'] != "") if ($item['title'] != "")
$body = "[b]".$item['title']."[/b]\n\n".$body; $body = "[b]".$item['title']."[/b]\n\n".$body;

View file

@ -55,9 +55,10 @@ function get_attached_data($body) {
$data = parseurl_getsiteinfo_cached($pictures[0][1], true); $data = parseurl_getsiteinfo_cached($pictures[0][1], true);
if ($data["type"] == "photo") { if ($data["type"] == "photo") {
$post["type"] = "photo"; $post["type"] = "photo";
if (isset($data["images"][0])) if (isset($data["images"][0])) {
$post["image"] = $data["images"][0]["src"]; $post["image"] = $data["images"][0]["src"];
else $post["url"] = $data["url"];
} else
$post["image"] = $data["url"]; $post["image"] = $data["url"];
$post["preview"] = $pictures[0][2]; $post["preview"] = $pictures[0][2];