Skip to content

Commit

Permalink
maintain image order
Browse files Browse the repository at this point in the history
  • Loading branch information
omzy committed Oct 31, 2017
1 parent f58003a commit 8bafb7c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Field/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public function process($field)
{
if ($ids = $this->fetchValue($field)) {
$connection = $this->post->getConnectionName();
$attachments = Post::on($connection)->whereIn('ID', $ids)->get();

$ids_ordered = implode(',', $ids);

$attachments = Post::on($connection)->whereIn('ID', $ids)
->orderByRaw("FIELD(ID, $ids_ordered)")->get();

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

Expand Down

0 comments on commit 8bafb7c

Please sign in to comment.