Differentiate between no description or an empty description
This commit is contained in:
parent
992b6eed1d
commit
2b3c1972db
2 changed files with 13 additions and 4 deletions
|
@ -179,7 +179,7 @@ class Upload extends \Friendica\BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('upload done');
|
$this->logger->info('upload done');
|
||||||
$this->return(200, "\n\n" . Images::getBBCodeByResource($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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -327,7 +327,7 @@ class Images
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getBBCodeByResource(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 = null): string
|
||||||
{
|
{
|
||||||
return self::getBBCodeByUrl(
|
return self::getBBCodeByUrl(
|
||||||
DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id,
|
DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id,
|
||||||
|
@ -347,8 +347,17 @@ class Images
|
||||||
public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = null): string
|
public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = null): string
|
||||||
{
|
{
|
||||||
if (!empty($preview)) {
|
if (!empty($preview)) {
|
||||||
|
if (!is_null($description)) {
|
||||||
return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
|
return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
|
||||||
|
} else {
|
||||||
|
return '[url=' . $photo . '][img]' . $preview . '[/img][/url]';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($description)) {
|
||||||
return '[img=' . $photo . ']' . $description . '[/img]';
|
return '[img=' . $photo . ']' . $description . '[/img]';
|
||||||
|
} else {
|
||||||
|
return '[img]' . $photo . '[/img]';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue