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

Customizing Thumbnails Issue #41

Closed
tschmidiger opened this issue Aug 23, 2018 · 5 comments
Closed

Customizing Thumbnails Issue #41

tschmidiger opened this issue Aug 23, 2018 · 5 comments

Comments

@tschmidiger
Copy link

tschmidiger commented Aug 23, 2018

When trying to customize the thumbnail URL generation method, $this->value is empty because $this refers to the current resource model and not the field class.

Image::make('Profile Photo')
    ->disk('public')
    ->thumbnail(function () {
        return $this->value
                    ? Storage::disk($this->disk)->url($this->value)
                    : null;
})

As a work-around I just replaced $this->value with $this->image which refers directly to the column name of the resource model.

@devmsh
Copy link

devmsh commented Aug 27, 2018

That's right, the docs need to be updated.

You can access the value using $this->value only within the preview override function within the Field classes, but if you override it in the Resource this will not work and you must use the column name as you do.

@dkulyk
Copy link

dkulyk commented Dec 4, 2018

In next release the value and disk properties will be pass to callback.

->thumbnail(function ($value, $disk) {
    return Storage::disk(value)->url($disk);
})

@jakobfdev
Copy link

@davidhemphill The docs need updating. I also had to check the issues to get past this.

@dillingham
Copy link
Contributor

@jboka maybe open a issue on https://github.com/laravel/nova-docs/issues detailing what needs to be updated in the docs / your workaround

@jakobfdev
Copy link

Created PR: laravel/nova-docs#123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants