I’m trying to come up with a solution to reuse media files across the site.
I’m thinking of using query: site.images
and have a “Media” tab in the site.yml where you can upload files and then use them globally.
Thoughts on this? Better solution?
I’m trying to come up with a solution to reuse media files across the site.
I’m thinking of using query: site.images
and have a “Media” tab in the site.yml where you can upload files and then use them globally.
Thoughts on this? Better solution?
It’s definitely an option, but from my perspective one that makes the most sense for a limited number of files that are used in multiple places all over the site.
Yes, that’s it. It’s a collection of featured media, videos… that you use here and there.
Ok, then I’d use those media elements in files fields etc. but combine that with a possibility to upload page specific media in textarea/editor fields.
I created a “Media” tab in site.yml but now all the images and .txt files in the root of the content folder is stressing me out a little
On this page Textarea | Kirby CMS
With the additional options you can fetch files from anywhere and upload them to specific pages.
Is it possible to put files in a folder instead of them being in the root?
Yes, you could also put them into a folder (don’t call it media
, though… What’s your problem with the files in the content root?
I tried the other scenario of creating a page called “Media” but with slug “m”. This is also nice but then much harder to find as it’s among the unlisted pages.
I like having “Media” as a tab and maybe it’s not an issue with all the files in the root. It just feels more organized having them in a folder.
That doesn’t really matter because you can still show these files in a tab of the “Dashboard” aka site.yml
. But then you would want a route to make this page inaccessible from the frontend.
I don’t really see a problem with files in the /content
folder, at least not from a user’s perspective because they don’t see the file system. It’s probably a more mental thing of the developer
I’ll let the files live in the /content folder. Definitely a mental thing
Hi all,
I am trying to have exactly this in my project (or at least I think it is the same):
In the panel i don’t see the files, all i I see is an empty files area. However I see them in the “Select” part when I want to add any.
My guess is that I only see them if they are listed in site.txt.
Is there a way to make them appear in the panel?
I can imagine that there is a solution I don’t see or that I have to add the files to site.txt with the file.create:after hook.
Any thoughts on this? Thanks a lot!
Could you please post your site.yml blueprint. Sounds as if you created a files field instead of a files section…
Wow, I totally missed that!
Now that I know it, it is obvious. However I was not aware that there is a difference between the two.
Thank you very much @texnixe!
For the record, and may it help others in distress here’s the blueprint that works.
tabs:
gallery:
label: "Gallery"
sections:
images:
label: Website Images
type: files
query: site.images
layout: cards
To make this work for all your uploads regardless of the page they are on, you need to set the parent to site, like so:
fields:
image:
type: files
query: site.images
uploads:
parent: site
Your images section in the gallery tab isn’t quite correct. A files section doesn’t have a query
property and no label
, but a headline
and a parent
.
tabs:
gallery:
label: "Gallery"
sections:
images:
headline: Website Images
type: files
parent: site #this is optional, default is the current page or the site
layout: cards
Thank you!
Hi! It is great to have the option to search and include image to page from another location.
But, if I take images from the site, then I lose page image possibility.
Example: now I have this on page
header:
label: Page header image
type: files
multiple: false
query: page.images
If I change the query to search for site images
header:
label: Page header image
type: files
multiple: false
query: site.images
I lose the possibility of page images.
Is there a solution to having both? Maybe to have a query from two locations?
site.images.add(page.images)
Oh, my, really
So many hidden features. This is superb Thank you!