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

Add resizable traits #2422

Merged
merged 3 commits into from
Jan 3, 2018

Conversation

handiwijoyo
Copy link
Contributor

@handiwijoyo handiwijoyo commented Jan 3, 2018

This traits will allow us to use thumbnail helper to generate image url when using Image additional fields. See: https://voyager.readme.io/docs/additional-field-options#section-image

Example of use:

use TCG\Voyager\Traits\Resizable;

class Post extends Model
{
    use Resizable;
}

Use it on view (usually on your site frontend):

@foreach($posts as $post)
    {{$post->thumbnail('small')}}
@endforeach

Or you can specify the optional image field name (attribute), default to image

@foreach($posts as $post)
    {{$post->thumbnail('small', 'photo')}}
@endforeach

@fletch3555
Copy link
Collaborator

@handiwijoyo, would you mind updating the docs for this?

@fletch3555 fletch3555 merged commit 8d68e9b into thedevdojo:1.0 Jan 3, 2018
@handiwijoyo
Copy link
Contributor Author

@fletch3555 I think we need to add new Helpers section in the docs, that will document all of available helpers function

@handiwijoyo handiwijoyo deleted the Patch/Add-resizable-traits branch January 4, 2018 15:30
@fletch3555
Copy link
Collaborator

I'm inclined to agree. I'll create the page later today if you'd like to suggest edits for it. Not sure if I can give you access to Readme.io, but if so, I'll do that instead

@def-media
Copy link

Please consider replacing "rtrim" function.

I had the next situation:
$name = rtrim('posts/January2018/OLJEeEfdQi4mI7Cgbhae.jpeg', '.jpeg')
which returns
"posts/January2018/OLJEeEfdQi4mI7Cgbha"
(missing the last "e" character in the string).

It seems like "rtrim" also removes the last character of the file name if that character is present in the file exstension.

I suggest replacing:
$name = rtrim($image, '.'.$ext);
with
$name = \Illuminate\Support\Str::replaceLast('.'.$ext, '', $image); .

It works in my case.

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

Successfully merging this pull request may close these issues.

3 participants