Closed sebastiangreger closed 3 years ago
@sebastiangreger Good question … currently, the editor uses a single field for handling all kinds of files. It might be a better ideas to have dedicated image and file buttons, which could then hold the corresponding config. I will definitely dig into this, as I also stumbled across this, when working with Kirby’s blocks field, because it also sets a blueprint for image uploads. We should find a good solution for this, so it won’t cause any trouble later on.
Maybe something like this?
editor:
label: My markdown editor
type: markdown
buttons:
file:
template: fileblueprint
or
editor:
label: My markdown editor
type: markdown
buttons:
file:
template:
image: image
document: attachment
Since this array from the blueprint should be available in the PHP script, this would be a versatile way to control these on a blueprint-to-blueprint basis? I'm thinking that using Kirby's file types would probably be sufficiently granular?
Yeah … somehow. The only problem is, that the uploader component is attached to the MarkdownInput
component and currently, uploads are handled separately from the button config. I have to investigate this a bit further. Maybe, using global upload options would be easier … don’t know yet.
@sebastiangreger I reviewed it this morning and unfortunately, this would complicate things a bit. The field would necessarily have to define that globally (not per button), so it wouldn’t matter if a user hits the upload button or just uses drag-and-drop. We are currently using the mixins provided by Kirby’s textarea field, which don’t support multiple templates per field.
Changing this would require to write our own implementation of these things, because it does not work like that anywhere else in Kirby. So I’d recommend to use a hook instead.
Changing this would require to write our own implementation of these things, because it does not work like that anywhere else in Kirby. So I’d recommend to use a hook instead.
Sounds good :+1: I'll see if I can contribute a paragraph with an example code snippet for the readme once I get it implemented :slightly_smiling_face:
Hi, just kicking the tyres of the
next
branch -- love it already, the plugin API for own button logic in particular! :heart_eyes:This is not specific to v2, since this is the same in the current version (I just never ran into it, apparently). I noticed that, when using the File button's upload option, the created images don't show up in my files section ...because I've configured a default file blueprint for that section so that all images get assigned
template: image
.Would there be an easy way to make this configurable in the Markdown Field? Could get messy though, since file uploads might demand different blueprints (e.g. my "Attachments" file section, separate from the one with images, assigns
template: attachment
to PDFs etc.). Of course a hook in the backend is always a fallback option.