+
+ /**
+ * Get a BBCode tag for an local photo page URL with a preview thumbnail and an image description
+ *
+ * @param string $resource_id
+ * @param string $nickname The local user owner of the resource
+ * @param int $preview Preview image size identifier, either 0, 1 or 2 in decreasing order of size
+ * @param string $ext Image file extension
+ * @param string $description
+ * @return string
+ */
+ public static function getBBCodeByResource(string $resource_id, string $nickname, int $preview, string $ext, string $description = ''): string
+ {
+ return self::getBBCodeByUrl(
+ DI::baseUrl() . '/photos/' . $nickname . '/image/' . $resource_id,
+ DI::baseUrl() . '/photo/' . $resource_id . '-' . $preview. '.' . $ext,
+ $description
+ );
+ }
+
+ /**
+ * Get a BBCode tag for an image URL with a preview thumbnail and an image description
+ *
+ * @param string $photo Full image URL
+ * @param string $preview Preview image URL
+ * @param string $description
+ * @return string
+ */
+ public static function getBBCodeByUrl(string $photo, string $preview = null, string $description = ''): string
+ {
+ if (!empty($preview)) {
+ return '[url=' . $photo . '][img=' . $preview . ']' . $description . '[/img][/url]';
+ }
+
+ return '[img=' . $photo . ']' . $description . '[/img]';
+ }