Articles of add image size

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 […]

Generating very small sized thumbnails from featured image

I want to create very tiny thumbnails that I can use in my sidebar. I want them to be around 5kb in size and be created automatically from the featured images. What’s the best way to do that?

Best way to receive special images in posts

Okay, this is what I’m thinking about (and it’s not a coding problem right now, but my fundamental thoughts): How to receive / input images in posts for special uses, let’s say a customized portfolio post. The post content should not really contain the Work images. These images should be styled specifically in an own […]

post thumbnail: increase dimension if smaller than… Possible?

I need thumbnails of minimum width: 400px. I would like that if the user uploads an image that is, say, 380px wide, WordPress creates a 400px-wide version. Is that possible?

A little confused as to what add image size actually does

I have a call to add_image_size like so: if ( function_exists( ‘add_theme_support’ ) ) { add_theme_support( ‘post-thumbnails’ ); } if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘sidebar_thumb’, 109, 60 ); } But then when I try to use that image size in my template… if ( has_post_thumbnail() ) { the_post_thumbnail( ‘sidebar_thumb’ ); } The […]

Resizing thumbnails retrospectively

I have a Custom Post Type called species – fishkeeping species profiles. Each species profile can have as many media attachments as it needs, plus a separate featured image. I’ve dealt with this by storing it in the postmeta table under the key attached_media and it’ll look something like this: a:3:{i:0;i:10081;i:1;i:10082;i:2;i:10083;}. This is an array […]

Custom image size mixes width and height in output

I want to use a couple of custom image sizes for a site that I’m developing. When I output the images I sometimes do not get the correct width size because it is mixed up with the height size. It guess it has something to do with how I declare the image sizes in the […]

the_post_thumbnail('my_image_size') always outputs full image

I’m developing a custom theme that uses several custom image sizes defined in my functions.php like this: add_theme_support(‘post-thumbnails’); add_image_size(‘featured_thumb’, 175, 120, true); I then get posts from the database and output on a page like this: $featured=get_posts(); if ($featured) { global $post; foreach($featured as $post) { setup_postdata($post); the_post_thumbnail(‘featured_thumb’); } wp_reset_postdata(); } But this code always […]

images not showing despite using add_theme_support('post-thumbnails');

I’ve got a system for post images where I have a specific category’s post thumbnail shown in the header, with a cropped version appearing in the blog #preview, and the full size image appearing in the full post. Images are not appearing in any of the 3 locations, and I’m not quite sure why. functions.php- […]