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

Cannot use the attr parameter with the @thumbnail directive #73

Closed
gmutschler opened this issue May 7, 2022 · 1 comment · Fixed by #82
Closed

Cannot use the attr parameter with the @thumbnail directive #73

gmutschler opened this issue May 7, 2022 · 1 comment · Fixed by #82

Comments

@gmutschler
Copy link

Hello Brandon,

I'm trying to use the @thumbnail directive and to add a CSS class to my image using the 3rd argument from the get_the_post_thumbnail() function.

Not sure if it's intentional since you also use the last parameter to echo the image URL (as per your documentation), but it seems that you forget to send this 3rd parameter to the WP function here:

if (! empty($expression->get(2))) {
if ($expression->get(2) === 'false') {
return "<?= get_the_post_thumbnail_url({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>"; // phpcs:ignore
}
return "<?= get_the_post_thumbnail({$expression->get(0)}, is_numeric({$expression->get(1)}) ? [{$expression->get(1)}, {$expression->get(1)}] : {$expression->get(1)}); ?>"; // phpcs:ignore
}


PS.: Thanks for everything you're doing with Roots and your own sage and acf extensions.

@EHLOVader
Copy link

I also needed this.

I think you were right @gmutschler, it appears to be a mistake. The third parameter is checked for boolean and if it wasn't then it was ignored. Instead it should be passed through on line 177.

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