Wordpress-Timthumb-alternative
Wordpress-Timthumb-alternative copied to clipboard
Allow 'width' or 'height' blank (or '0') values
To allow resize based on one dimension (like WordPress currently works)
I second that. It would be most helpful as I have just found out that the script currently does not do that. Unfortunately that means it's back to TimThumb for me for now.
Well, I haven't tested this but I believe you can already do that.... If for example you want to resize an image based on its height, you can use something like this: height: 300 width: 9999 (just a really high value) crop: false
so basically something like this should do the trick:
<?php matthewruddy_image_resize( $url, 9999, 300, false ); ?>
@aristath I tried the above but the script is actually resizing the image to 9999 x whatever. Can anyone else confirm that the above works?
Here's a fork with proportional cropping enabled (when width or height are set to null or false): https://github.com/proframework/Wordpress-Timthumb-alternative/blob/master/resize.php
This is an amazing script. Thank you. I also would really like to see this ability. @proframework your fork didn't work for me. I've dived in to trying to tweak it myself with no luck so far. Anyone else get it working?
@coryshaw, the same here. I just copy the code and test (changing, for eg, the height number to false, and a black image appears).
@proframework : I'm doing something wrong? what's the correctly way to use your updated script?
Hmm, my fork above is working well for me. All I have to do is set the width or height to "false", and proportional sizing will kick in.
So it would be something like this..
https://gist.github.com/proframework/6382826
First we check if width or height is set to false (using a shortcode).
Then we check if the width or height are empty (or false), if so, we turn off cropping.
Then if you do this:
[image width="false" height="300"]
It will resize the image proportionally.
Hope this helps.. Tom
Hello @proframework ! Thanks for your attention!
So, I can't understand what I'm doing wrong. Look my steps:
- include your forked code;
- in my template file, I call the function like this:
$img_des = matthewruddy_image_resize( 'http://www....com/file.jpg', 200, false, true, false );echo '<img src="'. $img_des['url'].' alt="" />; - the result is a black image
I'm running it in a local server (OSX + MAMP).
Hi there,
Maybe try this..
$img_des = matthewruddy_image_resize( 'http://www....com/file.jpg', 200, false, false ); echo '<img src="'. $img_des['url'].' alt="" />;
@proframework ! now it runs! the problem was my function markup! thank you very much!
Glad I could help :)