Move redir_private_images to Item::addRedirLinkToImageLinks()
This commit is contained in:
parent
4704bf6394
commit
a3e350313d
2 changed files with 26 additions and 26 deletions
|
@ -104,30 +104,6 @@ function qp($s) {
|
|||
return str_replace("%", "=", rawurlencode($s));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find any non-embedded images in private items and add redir links to them
|
||||
*
|
||||
* @param App $a
|
||||
* @param array &$item The field array of an item row
|
||||
*/
|
||||
function redir_private_images($a, &$item)
|
||||
{
|
||||
$matches = [];
|
||||
$cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
if (strpos($mtch[1], '/redir') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == Protocol::DFRN)) {
|
||||
$img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
|
||||
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Given a text string, convert from bbcode to html and add smilie icons.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue