So my scenario is: have Files field in Panel with multiple audio files uplaoded, but only one is selected. I have multiple languages, so when switching language, then selected file changes.
Problem starts, that I can not get that selected file. For example $audio->first() or $audio->current() returns first file in that list, but its not the selected.
My code:
$audio = $page->audio();
$audioFile = $audio->first(); // this returns first file... need to get selected file.
p.s. previously had dirty workaround where in foreach loop checking page content:
files: "- my_audio.mp3"
and compare this name with current iteration filename, but this is so dirty. And this stoped to work with Kirby v4, where file link is stored (because cannot compare with filename):
files: "- file://TmEHDWEOUSu1AJrN"