Builder blocks with spatie media library field

I am using the builder component with a spatie media library field in it. The builder field is stored in a json column. When however using two or more of these blocks, they all get the same image. This is quite logic as the images are related to a model and collection. Is there a way to make this work? I already figured out that I could make it work using a related model for each block but I am wondering if there is also a solution when storing in the json column?
11 Replies
Dan Harrin
Dan Harrin2y ago
doesnt work, because spatie doesnt store the json key that a file should be associated with
awcodes
awcodes2y ago
#curator works with builder and repeater. #media-library-pro might too, but can’t say for sure.
Dan Harrin
Dan Harrin2y ago
i have good experience with curator in the builder
Erwin.van.den.Berg
Thanks for the answers guys. I was thinking that it might work when you are able to add a key from the repeater/builder to the collection. Is there such a thing as the JSON key? or do you mean the index in the array? If there is a key would it then be possible to use this as the collection identifier?
Dan Harrin
Dan Harrin2y ago
ive tried to use it as the collection identifier before and it didnt work you are more than welcome to have a go
Daniel Plomp
Daniel Plomp16mo ago
@Erwin.van.den.Berg What solution did you go with? I'm also using a builder block with the Spatie MediaLibraryUpload field, but in my case nothing is stored in the json?
Daniel Kužela
Daniel Kužela13mo ago
Hey guys just discovered this post when I was trying to solve this issue finally managed it using hidden input with uuid and than spatie collection named after this input value like this
No description
Daniel Plomp
Daniel Plomp13mo ago
Hi @Daniel Kužela Wow, that is nice! Makes me questioning if I'm going with the Spatie Media Library, or Curator 🙂 How do you manage your images btw? Like, with Curator you have this online editor etc.
Daniel Kužela
Daniel Kužela13mo ago
Hey, did not have the chance to get to know Curator yet, but from what I see, I started with Spatie as I liked that instant generation of responsive images set and I see that curator is more of and file manager, but I am using only files related to specific model, so there is no need for this. Most of it is managed by Filament/Livewire, like cropping, resizing and stuff and once this is done, Spatie takes over and do other thinks like saving to db, generating thumbs or responsive images etc. And this specific issue I was trying to solve is to make something like Page Builder, where in Vue I just define some components and I can now use them in Builder. One more think I would love is to have preview of every builder component so is more user friendly rather than just names.
awcodes
awcodes13mo ago
FYI, Curator is a replacement for Spatie's Media Library. It also uses Glide to serve dynamically sized and formatted images. similar to Cloudinary, so you don't have to actually save or generate all your image sizes. 🙂
chrispage1
chrispage111mo ago
I've raised a PR that will provide a solution to this - https://github.com/filamentphp/filament/pull/10795 If you're able to give it a thumbs up that'd be great!
GitHub
Addition of 'whereCustomProperties' to Spatie media library file up...
Description Spatie Media Library within Filament has an inherent issue in that it's not easily achievable to use within repeaters/builders. Within a repeater field schema, currently there is no...
Want results from more Discord servers?
Add your server