php - Wordpress Function to change existing featured image size -
i using custom-community (cc) theme have created sub-theme have created functions.php file
the original cc theme has code in functions.php
// theme uses post thumbnails if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); set_post_thumbnail_size(222, 160, true); add_image_size('slider-top-large', 1006, 250, true); add_image_size('slider-large', 990, 250, true); add_image_size('slider-responsile', 925, 250, true); add_image_size('slider-middle', 756, 250, true); add_image_size('slider-thumbnail', 80, 50, true); add_image_size('post-thumbnails', 222, 160, true); add_image_size('single-post-thumbnail', 598, 372, true); }
i want change post thumbnail size 222x160 larger size, e.g. 400x300.
i have read codex on post thumbnails, function reference/add image size, function reference/set post thumbnail size, function reference/the post thumbnail, plugin api/filter reference.
unfortunately understanding of php still limited , in early-learning phase.
i have seen examples of sound similar problems elsewhere twenty-ten theme, nothing can understand or apply myself without functions.php locking me out, deleting on ftp , starting again.
i still unsure if possible add function sub-theme functions.php either unset/re-assign image size thumbnail (or other specified image type) in parent theme.
to clarify functions.php , sub-theme working correctly can confirm have used functions styling login, lack understanding achieve myself.
following tuts-plus tutorial (point 6 - remove additional image sizes) tried following code in functions.php:
//change thumbnail size function remove_parent_image_sizes( $sizes ) { unset( $sizes['post-thumbnail-size'] ); return $sizes; } if ( function_exists( 'add_image_size' ) ) { // 400 pixels wide , 300 px tall, cropped add_image_size( 'post-thumbnails', 400, 300, true ); }
i removed featured image post , applied new 1 still has dimensions 222x160.
still stumped :(
also tried way still no luck;
//change thumbnail size function remove_parent_image_sizes( $sizes ) { unset( $sizes['post-thumbnail-size'] ); return $sizes; } if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); set_post_thumbnail_size(400, 300, true); add_image_size('post-thumbnails', 400, 300, true); }
and adding line (modified stackexchange link) end caused site break:
add_action( 'after_setup_theme', 'remove_parent_image_sizes' );
you should first use remove_action()
or remove_filter()
functions remove parent theme behaviour , can add action of sub theme using add_action()
. here nice tutorial on how modify parent theme behavior within child theme reference.
Comments
Post a Comment