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

No way to change avatar size #1730

Closed
piotrkulpinski opened this issue Jun 15, 2018 · 4 comments
Closed

No way to change avatar size #1730

piotrkulpinski opened this issue Jun 15, 2018 · 4 comments
Assignees

Comments

@piotrkulpinski
Copy link

Expected behavior

I would like to be able to change the size of the avatar pulled by post.author.avatar.

Actual behavior

The avatar property always pulls the default gravatar size of 96x96.

Steps to reproduce behavior

Use post.author.avatar anywhere in the single.twig

What version of WordPress, PHP and Timber are you using?

WordPress 4.9.6, PHP 7.2.5, Timber 1.7.1

How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)

WP.org


Looks like the method is just pulling the deafult avatar without allowing to set any arguments for get_avatar_url function:
https://github.com/timber/timber/blob/master/lib/User.php#L148

@piotrkulpinski
Copy link
Author

Now, I know I can do post.author.avatar.src | resize('128x128') but it won't stretch the image if base size is 96px.

@piotrkulpinski
Copy link
Author

For everyone having same issue, the temporary workaround is to use raw WP function:
{% set avatar = fn('get_avatar_url', post.author.id, { 'size': 128 }) %}

@palmiak
Copy link
Collaborator

palmiak commented Jun 18, 2018

Hi

True - that is a problem - I always add:

function user_avatar( $size = '' ) {
        $args['size'] = $size;
        return get_avatar_url( $this->id, $args );
}

in Class that extends TimberPost so I can post.user_avatar(500). It should be a easy thing to do - maybe try making a PR?

@palmiak palmiak self-assigned this Nov 28, 2018
palmiak added a commit to palmiak/timber that referenced this issue Feb 22, 2019
jarednova added a commit to palmiak/timber that referenced this issue Feb 22, 2019
jarednova added a commit that referenced this issue Feb 22, 2019
@jarednova
Copy link
Member

@palmiak submitted a fix for this on #1928. Merged and will be released early next week!

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

No branches or pull requests

3 participants