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

Support for Letterboxing #3

Open
lmartins opened this issue Mar 8, 2016 · 9 comments
Open

Support for Letterboxing #3

lmartins opened this issue Mar 8, 2016 · 9 comments

Comments

@lmartins
Copy link

lmartins commented Mar 8, 2016

Any plans to support the letterboxing cropping mode:
https://github.com/jarednova/timber/wiki/Image-cookbook#letterboxing-images

@gchtr
Copy link
Member

gchtr commented Mar 8, 2016

Yeah, sure, that could be implemented.

What do you think, would it make sense to use letterbox like this in the image configuration?

'custom-4-crop' => array(
    // output should be 370, 370
    'resize' => array( 370, 370 ),
    // use letterbox with color #bada55
    'letterbox' => '#bada55',
)

When I’d use a parameter letterbox, it would take the resize parameters to letterbox the image.

In addition to that, I also thought about using the tojpg filter.

'custom-4-crop' => array(
    'resize' => array( 240 ),
    // convert to jpg with background #c0ffee when image is not a jpg
    'tojpg' => '#c0ffee',
)

When I’d use a parameter tojpg, it would convert PNGs to JPGs and use the assigned color to fill transparent space in the image (This is not possible with the normal Timber filter, but it’s possible if we directly go through a TimberImageHelper function).

Of course you could also use both. In that case it would first convert the image to JPG and then letterbox it.

Would it also make sense to use it with a twig filter? Like this:

<img {{post.thumbnail|to_jpg|get_timber_image_responsive('header')}}>

What do you think? I’ve never used any of the two filters before, so your opinion about how you could work with that would be nice ;).

@gchtr gchtr closed this as completed Mar 8, 2016
@lmartins
Copy link
Author

lmartins commented Mar 9, 2016

Sorry for not answering this before. We have a few hours difference. Your suggestions seem spot on I think.

@lmartins
Copy link
Author

lmartins commented Mar 9, 2016

Since the issue has been closed, is this something planned for a future release?

@gchtr
Copy link
Member

gchtr commented Mar 9, 2016

Huh? Why did I close that? Of course it’s not supposed to be closed!

Thanks for the feedback. I’ll implement this in the next days.

@gchtr gchtr reopened this Mar 9, 2016
@lmartins
Copy link
Author

lmartins commented Mar 9, 2016

@gchtr Thanks Lukas.

@gchtr
Copy link
Member

gchtr commented Mar 13, 2016

@lmartins Hey Luis.

I added support for letterbox and tojpg filters in 08ac4f3. When you download the latest version, you should be good to go.

@gchtr gchtr closed this as completed Mar 13, 2016
@lmartins
Copy link
Author

@gchtr Hi Lukas,

I can confirm it is now working. I couldn't get letterbox to work as a filter, as in <img {{ post.thumbnail|letterbox('#fff')|get_timber_image_responsive('product-tile') }} itemprop="image"> but other than that it is working great. Thanks man.

@gchtr
Copy link
Member

gchtr commented Mar 14, 2016

I didn’t implement the direct use of these filters in Twig yet. I’ll see what I can do.

@gchtr gchtr reopened this Mar 14, 2016
@lmartins
Copy link
Author

Ah ok. It is not essential in my use case, just a nice to have.

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

2 participants