Wordpress - add_theme_support('post-thumbnails') how to add size into function? -


i want keep code lean, , i'am wondering best way write code.

can include add_image_size function add_theme_support('post-thumbnails');, , how go it?

i want add images_size attributes post-thumbnails function.

if ( ! function_exists( 'rjk_setup' ) ) : function rjk_setup() { load_theme_textdomain( 'rjk', get_template_directory() . '/languages' ); add_theme_support( 'automatic-feed-links' ); add_theme_support('post-thumbnails');  register_nav_menus( array(     'primary' => __( 'primary menu', 'rjk' ), ) );  add_theme_support( 'html5', array(     'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );  add_theme_support( 'post-formats', array(     'aside', 'image', 'video', 'quote', 'link' ) );  add_theme_support( 'custom-background', apply_filters( 'rjk_custom_background_args',      array(     'default-color' => 'ffffff',     'default-image' => '', ) ) ); }endif; // rjk_setup add_action( 'after_setup_theme', 'rjk_setup' ); 

.

if ( function_exists('add_image_size') ) { add_image_size('tiny', 128, 79); add_image_size('small', 256, 158); add_image_size('medium', 384, 237); add_image_size('large', 512, 316); }; 

i hope clear mean.

there's no other way. have you're doing.

you have enable post thumbnails add_theme_support( 'post-thumbnails' ) onle args can pass array post types wanna enable post thumbnails add_theme_support( 'post-thumbnails', array( 'post' ) ); enable post thumbnails posts post type.

and create image sizes have use add_image_size( $name, $width, $height, $crop );

if ( ! function_exists( 'rjk_setup' ) ) :      function rjk_setup() {          add_theme_support('post-thumbnails');          if ( function_exists('add_image_size') ) {             add_image_size('tiny', 128, 79);             add_image_size('small', 256, 158);             add_image_size('medium', 384, 237);             add_image_size('large', 512, 316);         };     }   endif; add_action( 'after_setup_theme', 'rjk_setup' ); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -