spatie / medialibrary.pro

The source code of medialibrary.pro
https://medialibrary.pro
36 stars 9 forks source link

initial value not working #37

Closed sofia182 closed 3 years ago

sofia182 commented 3 years ago

Inside an edit form for the entity "service", we are passing

:initial-value="service.media"

to a media-library-attachment component but the preview is not rendered. However, when the user uploads a new image, the preview is correctly displayed.

Are we missing something?

freekmurze commented 3 years ago

Hi, please post your issue at https://github.com/spatie/laravel-medialibrary-pro

Thanks!

sofia182 commented 3 years ago

This link returns 404

Il giorno mar 29 dic 2020 alle ore 13:44 Freek Van der Herten < notifications@github.com> ha scritto:

Closed #37 https://github.com/spatie/medialibrary.pro/issues/37.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spatie/medialibrary.pro/issues/37#event-4154544617, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABONZF5664MNEUVGQLSDZS3SXHFKTANCNFSM4VNFILWQ .

freekmurze commented 3 years ago

What the email you've bought media library pro with? I'll take a look why you didn't get access to that private repo.

sofia182 commented 3 years ago

It's from the web agency I am working with: acquisti@doozy.it

freekmurze commented 3 years ago

I'll see if I can add you to that private repo. Meanwhile, you could check out our demo application: https://github.com/spatie/laravel-medialibrary-pro-app

It contains examples on how to integrate with Vue / React, you might find a solution there.

szenteskp commented 1 year ago

any solution for this problem? I'm facing the same bug.

GregPeden commented 9 months ago

For those reading later...

This works fine for me. Just make sure the initial value is formatted in a way which mirrors the server response when you upload a file. In practice you'll have to query your application for the necessary data set then transpose it to suit this library's expectations. If you use something like S3 with timestamped expiration keys then that means this has to be baked in ready to go.

For example:

        {
          "uuid": "a2ba22d3-e644-4473-b706-fa76954890d6",
          "name": "DALL\u00b7E 2023-11-10 10.57.46",
          "preview_url": "https:\/\/yourorg-yourproject-dev.s3.ca-central-1.amazonaws.com\/6bf31c9d6f669fb170bb101ba9cccd94\/f49d360845c9c9cdcf4f73b070d3e622DALL%C2%B7E-2023-11-10-10.57.46?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXTL7YW3J5TKGWSMO%2F20231128%2Fca-central-1%2Fs3%2Faws4_request&X-Amz-Date=20231128T200638Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=3e91c72f6dc26d1028a89adb84c1b9a04a1206942c017ba6a77a223639e09027",
          "size": 2224780,
          "mime_type": "image\/png",
          "extension": "png"
        },
        {
          "uuid": "6259aaf1-d922-432b-9c77-351e30e15599",
          "name": "Oct 2023 Victoria trip.png",
          "preview_url": "https:\/\/yourorg-yourproject-dev.s3.ca-central-1.amazonaws.com\/b58da80de1a2272f86382eb5ba21d0f4\/70bade7cd91f0ad21545f638206f49e5Oct-2023-Victoria-trip-preview.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXTL7YW3J5TKGWSMO%2F20231128%2Fca-central-1%2Fs3%2Faws4_request&X-Amz-Date=20231128T200632Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=acc86159aba834c0e41f730f4c135b086e246f87db4d3a607a39fc0f21cc48be",
          "size": 726162,
          "mime_type": "image\/png",
          "extension": "png"
        },

The components are very tolerant of some of the metadata missing, but the uuid, name and preview_url are fairly important to achieve expected functionality.