WordPress 3.5 – Add custom image size

You can pest following code in function.php. add_theme_support(‘post-thumbnails’); add_image_size( $name, $width, $height, $crop); add_image_size(‘Home Top’, 120, 120, true); add_image_size(‘Home bottom’, 270, 90, false); add_image_size(‘Archive thumb’, 150, 75, true); add_image_size(‘Special’, 397, 224, true); add_image_size( ‘Test cropped’, 500, 500, true ); function sgr_display_image_size_names_muploader( $sizes ) { $new_sizes = array(); $added_sizes = get_intermediate_image_sizes(); foreach( $added_sizes as $key => … Read more

wp_get_attachment_image() not working when trying to add width and height attributes

As written in the documentation, there are no attributes width and height in the fourth parameter of the function. What you might want to do is this: wp_get_attachment_image( $id, array( 10, 10 ) ); An alternative and recommended way is to define an image size which will lead WordPress to generate a thumbnail for this … Read more

Getting specific image thumbnail urls of attached images

Have a look at wp_get_attachment_image_src <?php $attachment_id = 8; // attachment ID $image_attributes = wp_get_attachment_image_src( $attachment_id, ‘medium’ ); // returns an array if( $image_attributes ) { ?> <img src=”https://wordpress.stackexchange.com/questions/169475/<?php echo $image_attributes[0]; ?>” width=”<?php echo $image_attributes[1]; ?>” height=”<?php echo $image_attributes[2]; ?>”> <?php } ?> Source: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src#Default_Usage

Completly disable and remove Thumbnails?

To remove all extra image sizes you use get_intermediate_image_sizes() in tandem with remove_image_size(). E.g. function remove_extra_image_sizes() { array_map( ‘remove_image_size’, get_intermediate_image_sizes() ); } add_action(‘init’, ‘remove_extra_image_sizes’); To edit the image size dropdown you can hook a custom function to image_size_names_choose filter. function filter_image_size_names_choose($size_names) { return array_filter( $size_names, function( $size_name ){ return ‘full’ === $size_name; }, ARRAY_FILTER_USE_KEY ); … Read more

Why is wp_get_attachment_image_src returning wrong dimensions? [duplicate]

I found the same issue here and the solution from there works. The solution is as simple as pasting this: $content_width = 2000;// Value higher than your new ‘large’ width in functions.php Explanation copied from there(user Chip Bennett): I believe your issue is that the value set for the global $content_width variable (which is 640px … Read more