| | |
| | | |
| | | public static function renderExistingAttachment(int $attachmentId, string $subtype):string |
| | | { |
| | | switch ($subtype){ |
| | | case 'video': |
| | | return static::renderVideoPreview($attachmentId); |
| | | case 'document': |
| | | case 'file': |
| | | return static::renderFilePreview($attachmentId); |
| | | default: |
| | | return static::renderImagePreview($attachmentId); |
| | | } |
| | | return match ($subtype) { |
| | | 'video' => static::renderVideoPreview($attachmentId), |
| | | 'document', 'file' => static::renderFilePreview($attachmentId), |
| | | default => static::renderImagePreview($attachmentId), |
| | | }; |
| | | } |
| | | protected static function renderUploadItemStart(?int $attachmentId = null):string |
| | | { |
| | |
| | | } |
| | | public static function renderImagePreview(?int $ID = null, ?array $additionalFields = null, bool $isTemplate = false):string |
| | | { |
| | | $out = static::renderUploadItemStart($ID, $isTemplate); |
| | | $out = static::renderUploadItemStart($ID); |
| | | //add image preview |
| | | if ($ID) { |
| | | $out .= jvbFormatImage($ID, 'tiny', 'medium'); |
| | |
| | | $plural |
| | | ); |
| | | break; |
| | | default: |
| | | $attr = false; |
| | | $single = false; |
| | | $plural = false; |
| | | } |
| | | |
| | | if (!$attr || !$single || !$plural) { |
| | | return ''; |
| | | } |
| | | $dataAttrs = []; |
| | | if ($config['update']) { |
| | | $dataAttrs[] = 'data-update="false"'; |
| | |
| | | $values = array_filter(array_values($values)); |
| | | return implode(', ', $values) ?: 'New Item'; |
| | | default: |
| | | if (strpos($tagFormat, '{') !== false) { |
| | | if (str_contains($tagFormat, '{')) { |
| | | $text = $tagFormat; |
| | | foreach ($values as $key => $value) { |
| | | $text = str_replace('{'.$key.'}', $value, $text); |