After renaming images: Forever gone in panel but correctly accessible in frontend

Hello,

if I rename an image (someday after download) in panel, they get “gone”. Does not matter if it’s the cover or the gallery. The image files are not deleted but renamed correctly. Files and associated txt-files are there: They are correctly renamed in the /content directory but the form fields in panel are now empty. It’s working fine in frontend, I checked the image paths via the browsers dev mode, it’s the correct renamed image name. I already tried to delete /media directory to “refresh the cache”. It seems to have something to do with the panel. I can delete or add images with no problems, the issue only happens on renaming.

Thank you for your help.

Maybe this snippet of that page blueprint helps:

...
sidebar:
  meta:
    type: fields
    fields:
      cover:
        type: files
        label: Cover
        layout: cards
        uploads:
          template: cover
        info: "{{ file.dimensions }}"
        max: 1
        required: true
      gallery:
        type: files
        label: Gallery
        min: 1
        required: true
        uploads:
          template: galleryimage
...

Your gallery and cover fields store the id (path) to the file. When you rename a file, the id stored in the fields is no longer valid.

So you have to update the information in these field via a file.changeName:after hook: file.changeName:after | Kirby CMS

This will get easier once Kirby implements permanent IDs for files (planned in upcoming 3.8 version).

Or you use the AutoID plugin now, but then you have to use a select field instead: GitHub - bnomei/kirby3-autoid: Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL.

Or you can use files sections with a template applied instead of the fields.

1 Like

Thank you for your response. I will try out that options.
Nice, this is adressed for future versions. SEO wise it would be to great to have the possibility to change the file name in the panel.
Great CMS so far, convinced the web agency I am working at, to give it a try. Works fine on my hobby project so far.

I don’t get it to work. I have worked with hooks on other CMS before but I have not the slightest idea what to put inside the hook to make it work as I am only recently working with kirby. On that hook google only shows few results yet. The plugin does not work with the given fields as you stated but alternative fields do not match the needs.
Looks like I’ll wait for 3.8.x and hide the renaming option for other users so far.