Unable to change display size of images larger than 640px in WordPress?

I met a problem when trying to change the media setting. The first pic wass about Media Setting and how big a large/medium/thumbnail image is. I tried to make large for 960px.

enter image description here

Read More

The second picture was what I saw when trying to resize image in editing page. But I couldn’t see the 960px option.

I’d tried some sizes smaller than 640px in Media Setting. It worked. And if for some larger than 640px, like 641px and 960px, it showed only 640px. It seemed not to be able to reach 960px that large.

enter image description here

So, why can’t I use 960px?

I used a blank theme to make styles from the ground. And so far, I’ve not changed any function for image setting at all.

Related posts

2 comments

  1. Most themes (esp. themes from wordpress) have a specific width limit (measured in pixels) for images inserted in a post or a page. Obviously, that limit depends on the theme’s main column width (which varies greatly from theme to theme).

    /wp-includes/media.php has:

    // we're inserting a full size image into the editor.  if it's a really big image we'll scale it down to fit reasonably
                    // within the editor itself, and within the theme's content width if it's known.  the user can resize it in the editor
                    // if they wish.
                    if ( !empty($GLOBALS['content_width']) ) {
                            $max_width = $GLOBALS['content_width'];
                    }
                    else
                            <strong>$max_width = 500;</strong>
    

    Try overriding with $GLOBALS['content_width'] = 960; in the theme’s function.php

  2. As @Debajyoti Das explains, there is a set content width for most themes.

    Either find the width in your theme and amend (search the files for 640) or if you have a child theme then add the following code in your functions.php which will usually override the themes width settings.

    For instance this works with the Understrap framework:

    // set theme width
    global $content_width;
    $content_width = 1024;
    

Comments are closed.