How can I replace TimThumb with WordPress native image tools? How can I replace TimThumb with WordPress native image tools? wordpress wordpress

How can I replace TimThumb with WordPress native image tools?


You can add custom thumbnails and use them within your code.

First you have to add theme support, set the thumbnail name, set the size, and set the size

add_theme_support( 'post-thumbnails' ); // this enable thumbnails and stuffsadd_image_size( 'mini-thumbnail', 60, 60, true );add_image_size( 'one-more-size', 300, 260, true );

You can then use this in your code by calling the following:

<?php while ( have_posts() ) : the_post();the_title();the_post_thumbnail( 'mini-thumnail' );the_excerpt(); ?>

Wordpress has a good reference page for this implementation and functions: https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/


I'm not sure if it's the most efficient way, but I have been able to get it working by replacing

<img class="<?php echo $solostream_img['class']; ?>" src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $solostream_img['url']; ?>&w=150&h=150&zc=1" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" />

with

<?php the_post_thumbnail('thumbnail'); ?>