Hello,
v4.5 here.
I’ve been programmatically updating files
fields, and I am having a brain-breaking problem.
I have pages with a files field that:
- Shows visually EMPTY in the panel.
- Is NOT EMPTY in the content file.
- Seems NOT EMPTY when programmatically checking it.
- The file it points at seems to exist when programmatically checking it.
This is the relevant bits of the blueprint declaration:
title: Publication
(...)
fields:
cover:
label: Cover Image
type: files
multiple: false
size: medium
layout: cards
translate: false
uploads: image
This is an example of how I updated the cover field:
$p->update([
"cover" => Data::encode([$filename], "yaml"),
]);
This is the relevant bits of content file for one of these pages:
Title: 1979 abril-maig
----
Cover: - file://ThGiumUCdevzznrJ
This is my debugging code:
$uuid = $p->cover()->yaml();
try {
$file = $p->cover()->toFile();
if ($file && $file->exists()) {
echo "✅ Cover file exists: “{$file->filename()}” (UUID: {$uuid[0]})<br>";
} else {
echo "❌ toFile() returned null (invalid UUID or no cover set) – stored value: “{$uuid[0]}”<br>";
}
}
This is the output for this particular page:
1979 abril-maig
✅ Cover file exists: “1979-guino-galeria-trece-web.jpg” (UUID: file://ThGiumUCdevzznrJ)
And this is how it looks in the panel, notice the apparently empty “cover” files field:
If I click on the field, the image shows with the right title:
Aaand, this happens in a LOT of these pages.
Help? Thanks