slimndap/TimberPhoton

Any way to make it work with default WP image sizes?

lmartins opened this issue · 7 comments

Im trying to get this to work with WordPress' default image sizes but instead of a hard cropped image I always get a fit image (which doesn't get cropped).

I've stumbled on similar issue before but it was my incorrect assumption. Now, as far as I can see in the docs, it seems to the the following use case was not implemented:

<img src="{{ post.thumbnail.src('medium') }}" />

Is that correct?

Hi Luis,

You are correct. this is not supported right now.
Does Timber support this at the moment?

Jeroen

Hey Jeroen,

Yes, Timber does support it:
https://github.com/jarednova/timber/wiki/Image-cookbook

Thanks again.

Ok. Do you know if it actually works with Timber?
If I look at the code it doesn't seem properly implemented.

Anyway, I guess I can be added to TimberPhoton relatively easy.
Do you think you can do it (with my help)?

I've been using it before and haven't noticed issues.
I'm no PHP expert by any means but I can manage to do it im more that interested to give it a go.

Let's do it then!

I guess you need to add a function to the TimberPhoton class that translate all available sizes (like 'medium') to a width and height in pixels. See: http://codex.wordpress.org/Function_Reference/get_intermediate_image_sizes

This will probably take me a while to figure it out, as I need to learn the Timber's API that it's being changed so I can understand where to inject the new code.
Please keep this open while I try to add the new functionality.

Thanks again Jeroen