Skip to content

Commit

Permalink
Fix connection issue with post meta
Browse files Browse the repository at this point in the history
Fixes gallery field on specified connection
  • Loading branch information
alex-jf authored Oct 15, 2019
1 parent 813ffb4 commit 9ee12a3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Field/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit 9ee12a3

Please sign in to comment.