Image width tag is less than the image pixel width – why?

I have been reading this morning about images uploaded via the Media Library in WordPress and I thought I had understood most of it. But there’s something I’m confused about.

My understanding is that there are a range of default image sizes – thumbnail, medium, large – which are generated when you upload an image. The maximum dimensions are set in your Media / Settings page in the admin panel.

My “Large” sizes are set to the default 1024px wide and 1024px high.

Image sizes

I have an image which I uploaded that was well over this size. What I’m confused about is when I insert the image into a post and select the large image size – it gives 640px as the width of the image.

Image Details

The HTML image tag generated on the post is this:

<img class="alignnone wp-image-1718 size-large" src="http://www.mysiteurl.com/wp-content/uploads/2013/01/DSC_7543-1024x767.jpg" alt="DSC_7543" width="640" height="479" />

You can clearly see the image is actually 1024px by 767px from the filename – DSC_7543-1024x767.jpg – so why is it being scaled to 640px by 479px by the tags?

Thanks very much for any help!

1 Answer
1

640px is the content size set in your functions.php. Here is an example of the content width set in the bundled theme twentyfourteen in twentyfourteen/functions.php#L28

if ( ! isset( $content_width ) ) {
    $content_width = 474;
}

In this example, the image size will be 474 px.

The content size will be the size used when images are inserted as attachments in the content when creating posts

EDIT

From the comments from the OP, to remove this restrictions, have a look at the 2 following posts

  • What is a good alternative to using $content_width for image optimization?

  • WHY THE $CONTENT_WIDTH WORDPRESS SETTING HURTS OPTIMIZATION.

Leave a Comment