Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to add more image sizes
Tagged: image size
- This topic has 4 replies, 2 voices, and was last updated 8 years, 2 months ago by
Martina.
-
AuthorPosts
-
March 4, 2015 at 4:30 am #143153
Martina
MemberDoes anybody know how to add more image sizes? I use the Eleven40.
Image sizes are mentioned here with a code snippet:
http://gregrickaby.com/genesis-code-snippets/But there is also mentioned I have to add the WP-Cycle-Plugin to get it work but the plugin is outdated.
http://www.martinaleukert.deMarch 4, 2015 at 5:37 am #143157Pixel Frau
MemberHi Martina. You can use this code in your functions.php file to add image sizes:
//* Add new featured image sizes add_image_size( 'home-bottom', 150, 100, TRUE );
home-bottom
is the name of the image size. You can call it whatever you want. 150 is the image width, and 100 is the image height.You might need to use the Regenerate Thumbnails plugin after adding an image size. This will create thumbnails for your new image size for the existing images in your media library.
March 5, 2015 at 2:08 am #143251Martina
MemberHi Pixel Frau,
unfortunately the code does not work. Nothing shows up in the media library to chose this sample size (I have uploaded a new large picture to try this).
I have found a code, but this works just for this indicated size but I don't know how to add a few more sizes:
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'new-size', 350, 250, true ); //(cropped)
}
add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
$addsizes = array(
"new-size" => __( "Rechteck")
);
$newsizes = array_merge($sizes, $addsizes);
return $newsizes;
}March 5, 2015 at 2:13 am #143252Pixel Frau
MemberAh, ok. The code does indeed work (those image sizes will be available in Genesis Featured Post widgets, etc. But you're right, it does not add the image size to the media library. That requires an additional step.
You can add something like this to functions.php:
//* Add new image sizes to post or page editor add_filter( 'image_size_names_choose', 'mytheme_image_sizes' ); function mytheme_image_sizes( $sizes ) { $mythemesizes = array( 'featured' => __( 'Home Size' ), 'portfolio' => __( 'Portfolio Size' ), ); $sizes = array_merge( $sizes, $mythemesizes ); return $sizes; }
Full explanation here.
March 5, 2015 at 4:39 am #143277Martina
MemberYup, that works like a charm. Thank you, I appreciate!
Thanks for posting the link, that makes everything clear.
Heres my full code (for 2 sizes I have added) just in case anybody is looking for it and has difficulties to put everything together - this is supposed to be in the functions.php:
//* Add new image sizes to post or page editor
add_filter( 'image_size_names_choose', 'mytheme_image_sizes' );
function mytheme_image_sizes( $sizes ) {$mythemesizes = array(
'featured' => __( 'Full Width' ),
'portfolio' => __( 'Tinas Mittel' ),
);
$sizes = array_merge( $sizes, $mythemesizes );return $sizes;
}//* Add new featured image sizes
add_image_size( 'featured', 800, 400, TRUE );
add_image_size( 'portfolio', 200, 300, TRUE ); -
AuthorPosts
- The topic ‘How to add more image sizes’ is closed to new replies.