1

I'm inserting an image in my theme as follows:

the_post_thumbnail('large');

Which results in the following HTML:

<img class="wp-post-image" width="660" height="440" sizes="(max-width: 660px) 100vw, 660px" srcset="/uploads/IMG-1024x683.jpg 1024w, /uploads/IMG-300x200.jpg 300w, /uploads/IMG-768x512.jpg 768w, /uploads/IMG-254x169.jpg 254w, /uploads/IMG-578x385.jpg 578w, /uploads/IMG-665x443.jpg 665w, /uploads/IMG-1600x1067.jpg 1600w" src="/uploads/IMG-1024x683.jpg">

Notice width="660" height="440" and sizes="(max-width: 660px) 100vw, 660px" which doesn't correlate with the size defined for large in Media Settings > Image sizes which is supposed to be 1024 x 1024.

What am I doing wrong?

6

WordPress uses min( intval($content_width), $max_width ) inside image_constrain_size_for_editor for large image size.

As I can see your $content_width is set to 660. So, change the $content_width in your functions.php file to the 1024 or whatever you need. For full-width layout, it's better to remove it.

Example: $GLOBALS['content_width'] = 1600. That's it.

If you don't know what content_width is, see Content Width for more info.

0

You're doing right. Just miss one step. I guess you upload image before change the size of large in setting. Final step is Regenerated thumbnail. Just install the plugin with same name, go to Tool > Regenerate thumbnail and click. ;)

  • I did not change the setting for 'large' at all. 1024 is the default for 'large'. – bart Apr 17 '16 at 2:41
  • Default large size is 640. Can you first still install thu plugin I said and try regenerate thumbnail. – Tung Du Apr 17 '16 at 2:46
  • If it's not work. Scan your code for the function that adjusted thumbnail size. Like: add_image_size or set_post_thumbnail_size – Tung Du Apr 17 '16 at 2:48
  • I did upload a brand new image, problem remains. – bart Apr 17 '16 at 2:50
  • I think there is some code that alter the behavior of thumbnail. Can you do my second advise – Tung Du Apr 17 '16 at 2:51
0

try this way

$image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'large', false);


<img src="<?php echo esc_url($image[0]);?>" alt="">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.