Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback url #126

Open
martin-ro opened this issue Jun 23, 2021 · 9 comments
Open

Fallback url #126

martin-ro opened this issue Jun 23, 2021 · 9 comments
Labels
bug Something isn't working

Comments

@martin-ro
Copy link

When using a fallack url no image is displayed. For example on a model like so:

public function registerMediaCollections(): void
    {
        $this->addMediaCollection('user-photos')
            ->useFallbackUrl(asset('images/default-user-photo.png'));
    }

The image field is blank. I also wasnt able to get it to work with the previewUsing and mediaOnIndex methods.

Any idea what the issue is? Thanks!

@dmitrybubyakin dmitrybubyakin added the bug Something isn't working label Jun 23, 2021
@dmitrybubyakin
Copy link
Owner

@martin-ro Hi. Looks like it's a bug. I'll look into it.

@bilogic
Copy link

bilogic commented Sep 1, 2021

Hi, any idea where the issue might be? I can try to find a solution.

@bilogic
Copy link

bilogic commented Sep 15, 2021

@dmitrybubyakin

Is there where the problem might be?

computed: {
usePreview() {
return this.media.previewUrl
&& !this.loadingFailed
&& !this.useFallback
},
},

@dmitrybubyakin
Copy link
Owner

@bilogic I think it's ok. It might be something else.

@bilogic
Copy link

bilogic commented Sep 15, 2021

I see.. sorry I don't know Vue, can't help much.

@petarthewizard
Copy link

This is method is not even available in my version, for some reason, and downloaded this a few days ago. Is this available only on the dev branch?

@petarthewizard
Copy link

I figured that useFallbackUrl is media-library specific method. So, I can, also, testify that it doesn't use the fallback URL when you delete an image.

@petarthewizard
Copy link

@dmitrybubyakin I couldn't find the code, but could the problem be that getMedia returns an empty collection when there is no media even when using useFallbackUrl. I think that you have to make a call to getFirstMediaUrl($collectionName) to get the fallback url.

@bilogic
Copy link

bilogic commented Oct 6, 2021

@dmitrybubyakin I also managed to get fallbackUrl working and have the same conclusion as @petethewizard. Don't think this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants