| | |
| | | if (!$found) { |
| | | error_log('Could not find a gallery upload field for post '.$ID); |
| | | } |
| | | |
| | | $meta->save(); |
| | | } |
| | | |
| | | |
| | | return [ |
| | | 'ID' => $ID, |
| | | 'usedUploads' => $uploadIds |
| | |
| | | $allIds = array_unique(array_merge($existingIds, $attachmentIds)); |
| | | $meta->set($data['field_name'], implode(',', $allIds)); |
| | | } |
| | | |
| | | $meta->save(); |
| | | } |
| | | |
| | | private function updateFieldValue(array $data, array $results): void |
| | |
| | | $allIds = array_unique(array_merge($existingIds, $attachmentIds)); |
| | | |
| | | $meta->set($data['field_name'], implode(',', $allIds)); |
| | | $meta->save(); |
| | | } |
| | | |
| | | private function getMetaManager(array $data): ?Meta |
| | |
| | | } elseif (str_starts_with($mimeType, 'video/')) { |
| | | $meta = Meta::forPost($postId); |
| | | $meta->set('video', $attachmentId); |
| | | $meta->save(); |
| | | } else { |
| | | $meta = Meta::forPost($postId); |
| | | $existing = $meta->get('documents'); |
| | | $existingIds = !empty($existing) ? explode(',', $existing) : []; |
| | | $existingIds[] = $attachmentId; |
| | | $meta->set('documents', implode(',', $existingIds)); |
| | | $meta->save(); |
| | | } |
| | | } |
| | | |