1
0
Fork 0

API: Support of privacy_image_cache for calls without entities added

This commit is contained in:
Michael Vogel 2014-06-16 22:36:59 +02:00
parent a1dbfdee65
commit e0219cf6af

View file

@ -1619,20 +1619,32 @@
return $ret; return $ret;
} }
function api_get_entitities($text, $bbcode) { function api_get_entitities(&$text, $bbcode) {
/* /*
To-Do: To-Do:
* Links at the first character of the post * Links at the first character of the post
* different sizes of pictures
* caching picture data (using the id for that?) (See privacy_image_cache)
*/ */
$a = get_app();
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
$image_cache = (count($result) > 0);
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false"); $include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
if ($include_entities != "true") if ($include_entities != "true") {
return array(); if ($image_cache) {
require_once("addon/privacy_image_cache/privacy_image_cache.php");
$a = get_app(); preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
foreach ($images[1] AS $image) {
$replace = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($image);
$text = str_replace($image, $replace, $text);
}
}
return array();
}
$bbcode = bb_CleanPictureLinks($bbcode); $bbcode = bb_CleanPictureLinks($bbcode);
@ -1712,9 +1724,6 @@
//$entities["media"] = array(); //$entities["media"] = array();
$offset = 0; $offset = 0;
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
$image_cache = (count($result) > 0);
foreach ($ordered_images AS $url) { foreach ($ordered_images AS $url) {
$display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url); $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url);
$display_url = str_replace(array("http://", "https://"), array("", ""), $display_url); $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);