gambitph / WP-OTF-Regenerate-Thumbnails

Automatically regenerates your thumbnails on the fly when thumbnail sizes change.
https://wordpress.org/plugins/otf-regenerate-thumbnails/
GNU General Public License v2.0
77 stars 16 forks source link

Use it Directly #1

Closed alihs closed 9 years ago

alihs commented 9 years ago

can we use it directly in the theme, something like http://alihussain.me/blog/how-to-make-the-get-the-image-wordpress-plugin-to-work-with-bfi-thumb/

bfintal commented 9 years ago

Yup you can use it directly, although now the only thing you need to do is a require_once. Nothing else :)

alihs commented 9 years ago

what would be the call function like earlier it was

$params = array( 'width' => 960, 'height' => 380, 'crop' => true ); echo "<img src='" . bfi_thumb( $image[url], $params ) . "'

will it be the same now?

bfintal commented 9 years ago

Nope, that's the old usage. This now conforms with the WordPress methods, so instead of echoing out the image paths, it's advisable to use WordPress' image functions to display images. Like wp_get_attachment_image & the_post_thumbnail

If you include OTF, then use those functions to provide the image sizes, images would get resized automatically.

On Mon, Jan 26, 2015 at 8:05 PM, alihs notifications@github.com wrote:

what would be the call function like earlier it was

$params = array( 'width' => 960, 'height' => 380, 'crop' => true ); echo "<img src='" . bfi_thumb( $image[url], $params ) . "'

will it be the same now?

— Reply to this email directly or view it on GitHub https://github.com/gambitph/WP-OTF-Regenerate-Thumbnails/issues/1#issuecomment-71451360 .

alihs commented 9 years ago

hmm, no there is now no way to call it directly. I ask cause what the earlier plugin helped me to do was resize images on the fly for different sections without using the functions/media settings to resize. Also in coalition with plugins like get-the-image bfi used to be very helpful.

Can it be considered to make the plugin work out of the default function or using BFI would be the best option?

bfintal commented 9 years ago

You can still do all of those: wp_get_attachment_image_src Then pass on the width & height in the $size parameter.

Right now I'm about to launch a WordPress theme. I have this in my functions.php:

add_image_size( 'feature-large', 920, 450, true );

Then I'm just using the size in my content:

the_post_thumbnail( 'feature-large' );

This would work as well:

the_post_thumbnail( array( 920, 450 ) );

alihs commented 9 years ago

Aah, I forgot that function existed. I'll try it out sometime soon and come back if I have any suggestions, questions and ideas. Thanks

bfintal commented 9 years ago

No problem! :+1: