getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.29k stars 168 forks source link

Files field: preview url stored in localStorage incorrect after replacing file in section #5566

Closed afbora closed 1 year ago

afbora commented 1 year ago

https://github.com/getkirby/kirby/assets/3393422/89384fbc-56e8-40e5-9a21-c8a97a09c65a

abb-76x.jpg:1 GET /media/pages/photography/test/2335848fdf-1693746160/abb-76x.jpg 404 (Not Found)

Kirby 3.9.6

distantnative commented 1 year ago

@afbora this is a files field or section?

afbora commented 1 year ago

This is album blueprint of starterkit:

columns:
  - width: 1/3
    # The first column contains a set of fields to store
    # information about the album.
    #
    # List of all available field types:
    # https://getkirby.com/docs/reference/panel/fields
    fields:
      # If you need the same field in multiple locations, you can define them once and reuse whereever needed.
      # Here we use a files field defined in `/site/blueprints/field/cover.yml`
      cover: fields/cover
      headline:
        type: text
        placeholder: "{{ page.title }}"
        help: Leave empty to use the title as headline
      subheadline:
        type: text
      text:
        type: writer
      tags: true

  - width: 2/3
    sections:
      # The `images` files section shows all images of
      # the current page that use the `image` template
      images:
        type: files
        layout: cards
        template: image
        info: "{{ file.dimensions }}"
        image:
          ratio: 5/4
          cover: true
        min: 1
        size: small
distantnative commented 1 year ago

@afbora can't reproduce this on v4/develop, can you? on v3 yes, I can.

afbora commented 1 year ago

@distantnative Yes, I can reproduce on v4/develop either.

distantnative commented 1 year ago

If it's fixed with v4-beta.1, I'd close this issue.

afbora commented 1 year ago

No, as I said that I can still reproduce the issue on v4/develop.

distantnative commented 1 year ago

Ok I forgot the "unsaved changes" part.

This is one of the issues where we store meta data (preview images etc.) with the actual field value - which is why it ends up in localStorage. And thus, the preview url doesn't get updated when the image is replaced.

Replacing the URL in localStorage would be quite difficult and a hack. I think we need to delay this and fix by only storing the value (file ids) and loading preview meta data separately.

distantnative commented 1 year ago

Actually duplicate of https://github.com/getkirby/kirby/issues/5103