TimberPhoton icon indicating copy to clipboard operation
TimberPhoton copied to clipboard

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

Open lmartins opened this issue 10 years ago • 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?

lmartins avatar Feb 17 '15 15:02 lmartins

Hi Luis,

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

Jeroen

slimndap avatar Feb 17 '15 16:02 slimndap

Hey Jeroen,

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

Thanks again.

lmartins avatar Feb 17 '15 16:02 lmartins

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

slimndap avatar Feb 17 '15 16:02 slimndap

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

slimndap avatar Feb 17 '15 16:02 slimndap

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.

lmartins avatar Feb 17 '15 16:02 lmartins

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

slimndap avatar Feb 17 '15 20:02 slimndap

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

lmartins avatar Feb 19 '15 09:02 lmartins