I realize this does not work since the images do not have a sort field in their accompanying text file (as I had in past projects). However, I am unable to find out how to automatically add this sort field, so the images can get sorted.
That’s what I initially thought as well. However, I sorted images in the panel and it still does not add a sort field to the images’ text files. Any idea what could be wrong?
I am using 3.3.2, but I guess since the issue is still open, there is no fix yet.
What would be my easiest way to work around that for now? The only thing I need to achieve is to have a files section on the first (‘site’) page of the panel. Any way to achieve this without the parent option?
Try to not set the parent option, then files are stored in the site instead of the given page (in my test this worked). Not useful, if you actually want to store the images in the home folder, though.
Ok, thanks, this easy fix works great for me in my specific case. Was not quite aware that the site itself can also hold media files.
Do I leave this question marked as issue or should I mark it as solved as there is already a GitHub issue to track the bug?
Hello had kirby 3.3.3 an I had this issue, updated to 3.3.5 and still have.
No sort data is saved in image.jpg.txt file
It just changes the sort order of the names of the images in the property.txt file
Can I do anything to solve it?
Thank You
In my template I have:
<?php foreach($page->images()->sortBy('sort') as $image): ?>
<?php endforeach ?>
My Blueprint:
title: Property
status:
draft: true
listed: true
columns:
- width: 1/2
fields:
text:
label: Text
type: textarea
size: large
metadescription:
label: Meta Description
type: text
icon: info-circle
- width: 1/2
fields:
codigo:
label: Código Buscador
type: text
calendario:
label: Código Calendario
type: text
imagenes:
label: Imagenes
type: files
layout: cards
uploads: image
image:
ratio: 8/4
cover: true
min: 1
size: small
And Blueprint Image:
title: Image
accept:
mime: image/jpeg, image/png
columns:
- width: 1/2
sections:
content:
type: fields
fields:
caption:
label: Caption
type: textarea
size: medium
- width: 1/2
sections:
meta:
type: fields
fields:
alt:
label: Alternative Text
type: text
photographer:
label: Photogapher
type: text
width: 2/3
license:
label: License
type: select
width: 1/3
options:
- Unsplash
- CC BY 4.0
- CC BY-SA 4.0
- CC BY-NC 4.0
- CC BY-ND 4.0
link:
label: Link
type: urlPreformatted text
@bootbricks You are using a files field, not a files section. A files field is basically a select field for files and stores the selected files in the page’s content file. Sorting the order of these files doesn’t change the sort field in the file meta data.
With $item->images()->sortBy(‘sort’) you fetch all images from the folder, not from your field.
Since your field has the same name as Kirby’s native method, you have to get your images via content and then convert into a files collection with toFiles():
This will give you the collection as stored in the content file.
If you instead want to sort by the sorting number in the file meta data, you can of course append sortBy('sort') to this collection, but I assume you want them in the order in which they appear in the field.
And yes, you can convert the field into a files section, of course, but keep in mind that a section will contain all images with the template “image” in the folder, not only the ones selected in the field.
In your template, you would then have to filter your files by that template.