Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

GRAV 1.7 page blueprint pagemedia vs file

Solved by pamtbaau View solution

Started by Sebastian 5 years ago · 3 replies · 902 views
5 years ago

Hey guys,

I'm updating a GRAV website right now to 1.7 and stumbled upon a problem with uploading images via admin.

Our page blueprint looks something like this:

YAML
        fileupload:
          type: file
          label: Bild hochladen
          destination: 'page@:/media'
          multiple: false
          avoid_overwriting: true
          accept:
            - 'image/*'
            - 'video/*'
            - '.pdf'

        header.image:
          label: Bild auswählen
          type: filepicker
          folder: 'page@:/media'
          preview_images: true

So we used the file field to upload images through admin and save those images in a folder called media and select the uploaded images by using type: filepicker

But with 1.7 type: file does not work anymore with page blueprints and the documentation recommends to use type: pagemedia https://learn.getgrav.org/17/forms/blueprints/fields-available#file-field

Is this by any means possible to upload images in GRAV 1.7 via admin and store them in a specific page folder?

btw type: pagemedia is not documented at all…

Thanks! 🙂

5 years ago

Ok figured out type: file still works when changing: destination: page@:/media' to destination: 'user/pages/media'

But anyway… if it's wrong to use type: file for pages what the right way to use type: pagemedia when defining a destination where to save the uploaded files?

5 years ago Solution

@seb3000, Shouldn't it be destination: 'page://media'?

See definition of File field and streams.

When I add the following to Quarks '/blueprints/default.yaml', an image is correctly added to folder 'user/pages/media':

YAML
file1:
  type: file
  label: Custom Logo Login Screen
  destination: 'page://media'
  accept:
    - image/*

👍 1
last edited 03/10/21 by pamtbaau
5 years ago

@pamtbaau:
page://media

Thank you for answering !

Super strange… I tried this yesterday and got an error while the image was uploaded. Tried it today after reading your post and it works…?

Anyhow… so now we got the type: file upload field working again which - regarding to the docs - you should not use for page blueprints. So what's the best practice for my use case?

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 132 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 127 7 months ago