Function renamed
This commit is contained in:
parent
7d91cc73de
commit
c5ca5bfdf8
5 changed files with 24 additions and 27 deletions
|
@ -375,7 +375,7 @@ function photos_post(App $a)
|
||||||
$arr['visible'] = 0;
|
$arr['visible'] = 0;
|
||||||
$arr['origin'] = 1;
|
$arr['origin'] = 1;
|
||||||
|
|
||||||
$arr['body'] = Images::getImageUrl($photo['resource-id'], $user['nickname'], $photo['scale'], $ext, '');
|
$arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
|
||||||
|
|
||||||
$item_id = Item::insert($arr);
|
$item_id = Item::insert($arr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,7 +489,7 @@ class Media
|
||||||
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
|
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
|
||||||
foreach ($pictures as $picture) {
|
foreach ($pictures as $picture) {
|
||||||
if (self::isLinkToImagePage($picture[1], $picture[2])) {
|
if (self::isLinkToImagePage($picture[1], $picture[2])) {
|
||||||
$body = str_replace($picture[0], Images::getPictureUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2], $picture[3]), $body);
|
$body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2], $picture[3]), $body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ class Media
|
||||||
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
|
if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img\]([^\[]+?)\[/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
|
||||||
foreach ($pictures as $picture) {
|
foreach ($pictures as $picture) {
|
||||||
if (self::isLinkToImagePage($picture[1], $picture[2])) {
|
if (self::isLinkToImagePage($picture[1], $picture[2])) {
|
||||||
$body = str_replace($picture[0], Images::getPictureUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2], ''), $body);
|
$body = str_replace($picture[0], Images::getBBCodeByUrl(str_replace(['-1.', '-2.'], '-0.', $picture[2]), $picture[2]), $body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1004,15 +1004,7 @@ class Media
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($media['type'] == self::IMAGE) {
|
if ($media['type'] == self::IMAGE) {
|
||||||
if (!empty($media['preview'])) {
|
$body .= "\n" . Images::getBBCodeByUrl($media['url'], $media['preview'], $media['description']);
|
||||||
$body .= "\n" . Images::getPictureUrl($media['url'], $media['preview'], $media['description']);
|
|
||||||
} else {
|
|
||||||
if (!empty($media['description'])) {
|
|
||||||
$body .= "\n[img=" . $media['url'] . ']' . $media['description'] . '[/img]';
|
|
||||||
} else {
|
|
||||||
$body .= "\n[img]" . $media['url'] . '[/img]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif ($media['type'] == self::AUDIO) {
|
} elseif ($media['type'] == self::AUDIO) {
|
||||||
$body .= "\n[audio]" . $media['url'] . "[/audio]\n";
|
$body .= "\n[audio]" . $media['url'] . "[/audio]\n";
|
||||||
} elseif ($media['type'] == self::VIDEO) {
|
} elseif ($media['type'] == self::VIDEO) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Friendica\Util\Strings;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,7 +179,7 @@ class Upload extends \Friendica\BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('upload done');
|
$this->logger->info('upload done');
|
||||||
$this->return(200, "\n\n" . Images::getImageUrl($resource_id, $owner['nickname'], $preview, $image->getExt(), '') . "\n\n");
|
$this->return(200, "\n\n" . Images::getBBCodeByResource($resource_id, $owner['nickname'], $preview, $image->getExt()) . "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -273,7 +273,7 @@ class Photos extends \Friendica\Module\BaseProfile
|
||||||
$arr['visible'] = $visible;
|
$arr['visible'] = $visible;
|
||||||
$arr['origin'] = 1;
|
$arr['origin'] = 1;
|
||||||
|
|
||||||
$arr['body'] = Images::getImageUrl($resource_id, $this->owner['nickname'], $preview, $image->getExt(), '');
|
$arr['body'] = Images::getBBCodeByResource($resource_id, $this->owner['nickname'], $preview, $image->getExt());
|
||||||
|
|
||||||
$item_id = Item::insert($arr);
|
$item_id = Item::insert($arr);
|
||||||
// Update the photo albums cache
|
// Update the photo albums cache
|
||||||
|
|
|
@ -318,30 +318,36 @@ class Images
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a link to a an image link with a preview
|
* Get a BBCode tag for an local photo page URL with a preview thumbnail and an image description
|
||||||
*
|
*
|
||||||
* @param string $resource_id
|
* @param string $resource_id
|
||||||
* @param string $nickname
|
* @param string $nickname The local user owner of the resource
|
||||||
* @param integer $preview
|
* @param int $preview Preview image size identifier, either 0, 1 or 2 in decreasing order of size
|
||||||
* @param string $ext
|
* @param string $ext Image file extension
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getImageUrl(string $resource_id, string $nickname, int $preview, string $ext, string $description): string
|
public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = ''): string
|
||||||
{
|
{
|
||||||
return '[url=' . DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id . '][img=' . DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview. '.' . $ext . ']' . $description . '[/img][/url]';
|
return self::getBBCodeByUrl(
|
||||||
|
DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id,
|
||||||
|
DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview. '.' . $ext,
|
||||||
|
$description
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a link to a picture with a preview
|
* Get a BBCode tag for an image URL with a preview thumbnail and an image description
|
||||||
*
|
*
|
||||||
* @param string $photo
|
* @param string $photo Full image URL
|
||||||
* @param string $preview
|
* @param string $preview Preview image URL
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/ public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string
|
||||||
public static function getPictureUrl(string $photo, string $preview, string $description): string
|
|
||||||
{
|
{
|
||||||
return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
|
if (!empty($preview)) {
|
||||||
|
return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
|
||||||
|
}
|
||||||
|
return '[img=' . $photo . ']' . $description . '[/img]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue