Updating image order in panel

If i change the image order in the panel it doesn’t affect the order in my front-end?
Also when I replace an image from a subpage the parent page still shows a preview of the old image. How do I handle this kind of behaviour? I want my user to be able to switch images around in the panel and display them in that order on the front-end and I need the first image to be the main image on the page.

Kind regards

Kenneth

You need to make sure your frontend uses the manual sorting order.

So something like this $page->images()->sortBy('sort')

As for this

Also when I replace an image from a subpage the parent page still shows a preview of the old image.

I’m not sure I understand what you mean.

I think i’ve did it right?
It just doesn’t update?
Thank you for the fast reply

I’m confused. The image in the screen below (the one with the stones) is not even in the gallery you posted above.

Where is that image coming from?

It comes from my content folder (which doesn’t properly update) when I change things in the panel. When I delete the image in the panel it is still in my content folder. And it is the first image link in there.

In your blueprint, Is that a files field? Or a files section?

Files field 53

Ah that explains what’s happening then.

Since it’s a files field you want to do something different then.
You want to convert the list of files stored in your gallerijfield into a files collection first.

$behandeling->gallerij()->toFiles()

Using ->images() returns all the images attached to that specific page.
That’s also why removing the image from the field doesn’t remove it from the folder.

You’re not actually deleting the image, you’re simply removing it from the list stored inside your txt file

1 Like

Files fields and Files sections work in a different way even though they look similar.
A files field allows you to store a reference list of files along with the rest of your content inside the txt file.

A files section on the other hand, doesn’t store anything inside the main txt file but allows you to access the files stored inside the content folder directly.

They can be confusing at first but you get used to both pretty quickly.

1 Like

So it would be better to use a section files instead for my problem?

I have no idea what your use case is so it’s hard to tell :slight_smile:
It usually depends by the type of page you have and how you want to handle things on the frontend.