From 9ee12a3f13962f988d679a902ead9e6ee298157c Mon Sep 17 00:00:00 2001 From: Alexandr Goncharov Date: Tue, 15 Oct 2019 21:50:55 +0200 Subject: [PATCH] Fix connection issue with post meta Fixes gallery field on specified connection --- src/Field/Image.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Field/Image.php b/src/Field/Image.php index f26b4fc..7d06ae2 100644 --- a/src/Field/Image.php +++ b/src/Field/Image.php @@ -133,7 +133,8 @@ protected function fillThumbnailFields(array $data) */ protected function fetchMetadataValue(Post $attachment) { - $meta = PostMeta::where('post_id', $attachment->ID) + $connection = $this->post->getConnectionName(); + $meta = PostMeta::on($connection)->where('post_id', $attachment->ID) ->where('meta_key', '_wp_attachment_metadata') ->first(); @@ -149,8 +150,10 @@ protected function fetchMultipleMetadataValues(Collection $attachments) { $ids = $attachments->pluck('ID')->toArray(); $metadataValues = []; + + $connection = $this->post->getConnectionName(); - $metaRows = PostMeta::whereIn("post_id", $ids) + $metaRows = PostMeta::on($connection)->whereIn("post_id", $ids) ->where('meta_key', '_wp_attachment_metadata') ->get();