Jump to content

Explicitly set image sort order


Mackski
 Share

Recommended Posts

Short answer, no.

But there are alphanumeric sort possibilities on run time. As $images is a Wirearray you could do:

$images = $page->images->sort('name');
foreach ($images as $key => $image) {
    echo "$key => " . $image->url . '<br>'; // hyatt2.jpg => /site/assets/files/1/hyatt2.jpg
}

This will, sort the images on filename.

--

And you can re-save the page with the new sort order.

// Page is previously saved, but now we reset the order
$page->images->sort('name');
$page->of(false);
$page->save();
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...