Articles of add image size

How risize a thumbnail?

I have a wordpress thumbnail, but i when set the size this (500,200) wordpress resize the imagen and let it square, only 500×500. I set in functions.php add_image_size (‘single_post’,500,200) In the theme if(has_post_thumbnail()) { the_post_thumbnail(‘single_post’); } Can anyone help me please?

Why isn't add_image_size('event-secondary-image-thumbnail', 250, 150) working?

I am using a plugin called multi post thumbnails so that I can have more than one featured images for each post. I have a custom post type called event. The class multiPostThumbnails exists . it displays the images, it just doesn’t restrict them to 250 by 150 pixels. How can I make this work, […]

Overwrite add_image_size defined by theme

I bought a WP-Theme which defines a custom image-size in his theme-functions.php like this: if ( function_exists( ‘add_image_size’ ) ){ add_image_size( ‘tie-small’, 70, 70, true ); } As you can see the third-parameter is true, which results in hard crop mode (see WordPress Documentation for add_image_size). This mode isn’t taking care of the proportions so […]

Why does the Hard Crop option Scale?

I have a number of custom image sizes. I noticed earlier, when I was publishing a new post, that the post image was cropped AND scaled. It is exactly the right dimensions.. but it isn’t the portion of the image it should be. This is the code in functions.php, for this particular image size. add_image_size( […]

Function to insert missing image size attributes into img tags

I want to add a custom function to scan my website and automatically insert image size attributes that are missing on my pages. For example, if there is an image on one of my pages that looks like the following: <img src=”http://img.mywordpresstips.com/functions/img.jpg” alt=”Image Title”> If img.jpg actual size is 150×50 px, the function would pick […]

One of my image sizes isn't showing up in srcset

So for I’ve added some custom image sizes like this: add_action(‘after_setup_theme’, ‘image_sizes_setup’); function image_sizes_setup(){ add_theme_support( ‘post-thumbnails’ ); add_image_size(‘thumb-small-2x’, 196, 9999); add_image_size(‘thumb-medium-2x’, 276, 9999); add_image_size(‘portrait-thumb-large-2x’, 328, 9999); add_image_size(‘landscape-thumb-large-2x’, 9999, 328); add_image_size(‘small-2x’, 900, 600); add_image_size(‘medium-2x’, 1200, 800); add_image_size(‘large’, 1920, 1280); add_image_size(‘large-large-2x’, 2160, 1440); add_image_size(‘extra-large-2x’, 2400, 1600); } Then I wrote this code so I can select them […]

How to add a new image size and apply it to posts only?

I’d like to create a new image size and write another function that basically says that if I’m applying this new image to any posts to use this new image size. function add_image_size( ‘story_thumb’, 640, 640, array( ‘center’, ‘center’ ) ); Is the function I have for the new image size. I want it to […]

JointWP – Can't add custom images sizes

I am trying to add a custom image size in the functions.php file. add_image_size( ‘Portrait’, 1200, 1800, false ); add_image_size( ‘Featured’, 2560, 1600, true ); This is the newest version with foundation 6. Am I putting it in the wrong file? Thanks for any help.

Get all custom sizes in srcset attribute

I have three custom sizes: add_image_size( ‘img-movil’, 667, 667, true ); add_image_size( ‘c200x200’, 200, 200, true ); add_image_size( ‘c400x400′, 400, 400, true ); And I’m tring to get them into the srcset: $img_srcset = wp_get_attachment_image_srcset( $img_id, array( ‘c200x200’, ‘c400x400’, ‘img-movil’ ) ); srcset=”<?php echo esc_attr( $img_srcset ); ?> But I get this into the srcset: […]

Using Image Sizes for Custom Post Types outside the Loop

I want to use an image size on a Custom Post Type (which has featured image enabled). in functions.php I added: add_theme_support( ‘post-thumbnails’ ); add_image_size( ‘my-non-working-size’, 600, 300, true ); The custom post type is called ‘homeslide’ as I use it to build a a carousel slider on home. To get all my slides I […]