Skip to content

Commit

Permalink
Merge pull request #18 from tlaverdure/patch-5
Browse files Browse the repository at this point in the history
Only process if there are ids
  • Loading branch information
jgrossi authored Feb 15, 2017
2 parents a987e53 + a76ad15 commit 9bc8696
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Field/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ class Gallery extends Image implements FieldInterface
*/
public function process($field)
{
$ids = $this->fetchValue($field);
$connection = $this->post->getConnectionName();
$attachments = Post::on($connection)->whereIn('ID', $ids)->get();

$metaDataValues = $this->fetchMultipleMetadataValues($attachments);

foreach ($attachments as $attachment) {
$image = new Image($this->post);
$image->fillFields($attachment);
$image->fillMetadataFields($metaDataValues[$attachment->ID]);
$this->images[] = $image;
if ($ids = $this->fetchValue($field)) {
$connection = $this->post->getConnectionName();
$attachments = Post::on($connection)->whereIn('ID', $ids)->get();

$metaDataValues = $this->fetchMultipleMetadataValues($attachments);

foreach ($attachments as $attachment) {
$image = new Image($this->post);
$image->fillFields($attachment);
$image->fillMetadataFields($metaDataValues[$attachment->ID]);
$this->images[] = $image;
}
}
}

Expand Down

0 comments on commit 9bc8696

Please sign in to comment.