aurelianspodarec's avatar

Managing Spatie Media Library images

Hi there!

So I've installed Spatie for my project, and I'm having hard time following their docs...

My first question is, how is Spatie meant to work conceptually speaking?

I have a page images table, on the left and the created spateie media table.

Now, if I upload an image, which is a variation of the page, where and how is the image stored? How do I retrieve the image? I uploaded the images using filament but I'm just confused how this is mean to work.

Each image will need a thumbnail, and different quality and sizes as well, basically optimized.

But first thing first, how do I even display an image associated to the page? I assume by model_id right, so in that case I need to delete the 'image' from my table?

Also, I don't think its appropriate to store ALL images in media either. But a categories like pages, components houes makes more sense to me, as if someone is looking for houses, and there are 1million records, then why search though all images right?

0 likes
1 reply
aurelianspodarec's avatar

I feel like, the media table created from spatie exists to hold all images.

  • It gets the model_id which in this case is the id of page images.
  • Then based on the page image id, I fetch the media with a new method on my model.
  • I should delete my image from page_images.

But not sure if that's the best because the media will be divided. If you have animals, are you going to store all 100million dog pictures in media, all 100million cat pictures in media, all 100million of horse pictures in media? You get the idea. So I would assume we would have media_animals_dog table to store all dog picture as well.

Am I thinking right or getting messed up somewhere?

Please or to participate in this conversation.