Default WordPress Image Sizes and How to add Custom Sizes

Default WordPress Image Sizes and How to add Custom Sizes

When you upload an image, WordPress does a lot of work behind-the-scenes so you can serve the image to your visitors. You can piggyback on this process and add custom image sizes to save yourself from having to resize images manually.

In this post, I’ll explain how and why WordPress creates different image sizes. Then I’ll teach you how to add your own image sizes by modifying the functions.php file, regenerate thumbnails and add your new image sizes to the Gutenberg image block and/or the WordPress loop.

WordPress Image Sizes Explained

Every time you upload an image into the WordPress media library, these are the additional image size options WordPress creates by default:

  • Thumbnail
  • Medium
  • Medium Large
  • Large

If your theme specifies additional image sizes, WordPress creates those as well.

WordPress also preserves the original size you upload and names it Full as in full-size.

You can see all of these (with the exception of Medium_Large) in the Gutenberg image block Image Size drop down when inserting an image into a page or post.

Why does WordPress create so many images?

Images are like pants. You want to make sure you get the right size. Pants and images that are too small look silly and it’s painfully obvious to you and everyone else that they don’t fit right. Too small images on your site will look stretched out or pixellated.

By contrast, if they’re too large, that’s super wasteful. You wouldn’t put a pair of pants made for a man on a baby, right? It’s so much extra fabric that isn’t even necessary. That baby is going to get lost in a pant leg 😉

Images are the same. If your image is too large for the container, you’re wasting bandwidth and time downloading it to serve on your page. And for what? For nothing.

Ideally, the full-size images you upload should be big enough to fit the largest image container on your site, but no larger. Then when you use images on your site, you should use the exact size image you need.

Since scaling images to create the right size in Photoshop or other image editor takes valuable time, WordPress takes on this task and does it for you. Thanks, WordPress!

All you need to do is choose the appropriate size when inserting an image into your site to get the performance benefits of using an image that is just right.

If the WordPress default image sizes aren’t perfectly sized for your theme, you can adjust the defaults in the Media > Settings section or add custom sizes so you’ll have more options to choose from.

Screenshot of WordPress Media settings
The WordPress default image sizes, except for medium_large which is hidden by default

The default image sizes are as follows:

  • 150px square for thumbnails
  • 300px width for medium images
  • 768px max width for medium_large images
  • 1024px max width for large images.

Medium_large was added to take advantage of responsive image support, which is why it isn’t included in the settings page. Speaking of responsive images…

Responsive Images

All of these images in various sizes serve another purpose, so you shouldn’t set the defaults to zero to keep WordPress from creating them, as some tutorials suggest.

WordPress added responsive images to core in version 4.4. Instead of populating image src attributes with the URL for just one image, WordPress also added srcset (set of sources) which is a list of URLs of images of various sizes.

Guess what images it uses to create that list? Yup, WordPress uses the same images at different sizes it creates when you upload an image.

It offers this list to the browser so it can select an image that is appropriate for the visitor’s device. If the visitor is using a mobile device, they’ll receive a smaller image in the srcset. If they’re visiting your site on a desktop Retina device, then they’ll receive the full-size Retina-ready image file you uploaded. Again, this is why you should upload an image big enough to fill that need.

When you add a custom image size, WordPress will add it to the srcset as long as it has the same aspect ratio. If the custom image size crops the image into a different shape then it will be omitted from the set.

WordPress Thumbnails and Featured Image Size

We’ve now reached the part of our tutorial where we will unravel the whole thumbnail/featured image mess. Basically, the problem boils down to this; because WordPress maintains backward compatibility as it evolves, the names of things change, but the functions still refer to things by their old names.

The WordPress Thumbnails image size was introduced in version 2.9 but was quickly changed to Featured Images in version 3.0, but alas, the name stuck. So you’ll often hear featured images referred to as thumbnails in tutorials and even in the function names.

Screenshot of Featured Image Metabox
If you don’t have the featured image meta box, paste add_theme_support( ‘post-thumbnails’ ); into your functions.php file

Here are some examples:

  • If your theme doesn’t have featured images and you want to enable that feature, you’ll add add_theme_support( 'post-thumbnails' ); to your functions file.
  • To display the WordPress featured image size in a theme, you’ll use the_post_thumbnail() function.

Thumbnails and featured images share a default size of 150px by 150px. If you use the_post_thumbnail() function without an argument to specify the size, it will use the default 150px square size.

To make this less confusing for yourself so you can actually use the right size, I suggest creating a custom image size and naming it featured-large or something similar. Then, when you want to use that image in you’re the loop, you’ll use the_post_thumbnail('featured-large').

Before You Start Creating Custom Image Sizes in WordPress

As you start creating custom image sizes, avoid going overboard and creating images for every conceivable purpose. Otherwise, you’ll burn through space on your hosting and if you’re using an image optimization service that charges you per image, you’re going to go through your image allowance a whole lot faster.

If your plan allows you to optimize 100 images but every upload generates 9 additional sizes that also need to be optimized, you’ll hit your limit once you upload 10 images. Keep this in mind when adding custom sizes and choosing image optimization plans.

Smush Pro doesn’t have image optimization limits and comes with a CDN so you can keep your server storage space clear. You’ll be able to add more custom image sizes than you normally would. Think of it as the equivalent of putting flowy MC Hammer pants instead of little skinny jeans on those babies because the fabric is cheap 🙂

Try Smush Pro free for 30 days.

How to Add Custom Image Sizes in WordPress

Here is the code we’re going to be adding to our functions file to add image sizes:

add_image_size( 'the-name-for-custom-image-size', 600, 400, true );

This function accepts 4 parameters in this order:

  1. The name you give your custom image size
  2. The image width in pixels
  3. The image height in pixels
  4. Should the image be cropped to fit the width and height you specified above


The cropping parameter is a boolean, so you’ll use true or false. If you leave it out entirely, then it will default to false.

If you set the cropping parameter to true, then WordPress will crop your image to fit the dimensions you specify when it creates the custom image.

For example, if your custom image size is a 600px by 600px square and you set cropping to true, then if you upload a 600px by 800px rectangular image, 200px will get chopped off to make the image square.

add_image_size( 'custom-image-square', 600, 600, true );

Setting the cropping parameter to true is helpful for image sizes that have to be exact, like featured images or post archive images that have to fit a certain dimension perfectly.

For images that can have more wiggle room, such as the WordPress post image size and images on pages that tend to have variable heights and widths, then you can set cropping to false. This will resize the images, but it won’t change the shape of the image or cut off any pixels.

Take a look at our image SEO guide if you’re trying to drive traffic to your sites with your images.

Regenerating Thumbnails

One of the most important steps when either:

  1. modifying the WordPress default image sizes
  2. adding custom image sizes or
  3. switching over to a new theme that has different custom sizes

is regenerating thumbnails.

In this context, thumbnails refers to all the additional images WordPress creates, including the custom image sizes that are included in your theme and the ones that you create via your functions file.

When you make a change to the way that WordPress creates additional images, then it will only affect the images you upload going forward. It doesn’t update the images that are already in your media library.

To change the images you’ve already uploaded, you’ll have to use the popular Regenerate Thumbnails plugin.

After you install it, you’ll find it in the Tools section.

Screenshot regenerate thumbnails settings
Just push the button to create new image sizes

When you regenerate your thumbnails in your new sizes, you’ll have the option to delete old unused image sizes to free up server space.

How to Add Custom Image Sizes to the drop-down in the Gutenberg image block

You only need to add the code below to your functions file if you want your custom image sizes to appear in the drop-down in the Gutenberg image block. If you created a custom image size to use behind-the-scenes for your theme, you can skip this step.

Screenshot Gutenberg Image Block Sizes Dropdown
Here’s the custom image size I’m adding with the code below

We’re going to be hooking onto the image_size_names_choose filter.

In the array, I’ll add the name of the custom size that I specified in the add_image_size function and the name that I want to appear in the drop-down within the parentheses.

As I learned when doing this tutorial, you’ll have to regenerate thumbnails before the image appears in the drop down.

WordPress Add Image Size Full Code Snippet

Next, we’ll combine everything we learned into one code block with a real-world example.

Let’s say you want to add custom image sizes to your blog.

Here are the image sizes you want to add:

  • A 1600px by 400px featured image
  • An 800px size that spans the width of your blog’s content section

Since our theme doesn’t currently support featured images, we’ll start with that.

You’ll then see my custom sizes. Notice that I didn’t crop the images that are going to span the width of the blog content. I will hard crop my featured images since I want them to line up just right.

The only image I want to add to the Gutenberg drop down is the blog image since I’ll be using the WordPress featured image size in my theme.

After I add this code to my functions.php file, the next step is to regenerate thumbnails.

To use my custom featured image for my posts in the loop, I’ll add the following to single.php or index.php

See how I added 'featured-large' in the_post_thumbnail() function? That will display my featured image below my blog posts titles, above my content.

Custom Image Sizes Best Practices

Here are a few more tips so you don’t run into trouble creating custom images in WordPress.

  1. Always upload the largest file you can. If your image size is too small, WordPress won’t be able to create all the sizes it needs to serve your images properly on a variety of devices.
  2. If you need to resize the medium_large default size, use the update_option() function. You can use this same function to update any other WordPress default image size.
  3. If you’re outside the WordPress loop, you can use the function get_the_post_thumbnail() to use one of your custom images.
  4. Here’s more on soft cropping and hard cropping when creating custom images sizes in case you run into trouble.

That’s All There is to Adding Custom Image Sizes

Once you understand how custom image sizes in WordPress work, you can modify them to fit your needs and save a lot of time. Getting your image sizes right also helps you improve your site performance and search engine rankings, so it is an important thing to get right.

If you really want to take your image optimization to another level, check out Smush. We’ve added an amazing CDN to Smush Pro that has automatic image resizing, which will help you avoid dealing with modifying your functions file to add custom image sizes.

There are also other great image optimization features that come built-in, like lazy loading and converting images to next-gen formats. Try Smush Pro free for 30 days and see how the image optimization features can improve your site.

Related posts:

  1. How to Properly Resize and Serve Scaled Images with WordPress Serving scaled images is one of the most overlooked ways…
  2. Best Image Formats for Websites Compared! PNG, JPG, GIF, and WebP Image Optimization begins with choosing the best file format for…
  3. How to Make Retina-Ready Images That Don’t Slow Down WordPress The images on my site looked decent and loaded quickly….
  4. 6 Lazy Load Plugins to Make Your WordPress Site Faster Sites with a ton of images can take forever to…


via WPMU DEV Blog

April 11, 2019 at 06:22AM

WordPress 5.2 Beta 3

WordPress 5.2 Beta 3

WordPress 5.2 Beta 3 is now available!

This software is still in development, so we don’t recommend you run it on a production site. Consider setting up a test site to play with the new version.

There are two ways to test the latest WordPress 5.2 beta: try the WordPress Beta Tester plugin (you’ll want to select the “bleeding edge nightlies” option), or you can download the beta here (zip).

WordPress 5.2 is slated for release on April 30, and we need your help to get there! Thanks to the testing and feedback from everyone who tried beta 2, nearly 40 tickets have been closed since then. Here are the major changes and bug fixes:

  • The new Site Health feature has continued to be refined.
  • Plugins no longer update if a site is running an unsupported version of PHP (see #46613).
  • It’s now more apparent when a site is running in Recovery Mode (see #46608).
  • The distraction free button no longer breaks keyboard navigation in the Classic Editor (see #46640).
  • Assistive technologies do a better job of announcing admin bar sub menus (see #37513).
  • Subject lines in WordPress emails are now more consistent (see #37940).
  • Personal data exports now only show as completed when a user downloads their data (see #44644).
  • Plus more improvements to accessibility (see #35497 and #42853).

Minimum PHP Version Update

Important reminder: as of WordPress 5.2 beta 2, the minimum PHP version that WordPress will require is 5.6.20. If you’re running an older version of PHP, we highly recommend updating it now, before WordPress 5.2 is officially released.

Developer Notes

WordPress 5.2 has lots of refinements to polish the developer experience. To keep up, subscribe to the Make WordPress Core blog and pay special attention to the developers notes for updates on those and other changes that could affect your products.

How to Help

Do you speak a language other than English? Help us translate WordPress into more than 100 languages! The beta 3 release also marks the soft string freeze point of the 5.2 release schedule.

If you think you’ve found a bug, you can post to the Alpha/Beta area in the support forums. We’d love to hear from you! If you’re comfortable writing a reproducible bug report, file one on WordPress Trac, where you can also find a list of known bugs.

Would you look at that
each day brings release closer
test to be ready


via News – –

April 12, 2019 at 02:42PM

Envato Launches Elements: The Biggest FREE Elementor Template Resource

Envato Launches Elements: The Biggest FREE Elementor Template Resource

With Elements, our users can enjoy access to an unimaginable and ever-growing number of templates and images, as well as other design assets which will be integrated into the editor in the future.

Envato is connecting their Envato Elements subscribers into this plugin, offering them a complete suite of everything a web professional might need to build a website.

With an Envato Elements subscription, you’ll have access over 1,000,000 assets across graphics, video, music, sound effects, fonts, and even courses and educational material.


via Elementor Blog

April 11, 2019 at 03:09AM

WordPress 5.2 Beta 2

WordPress 5.2 Beta 2 is now available!

This software is still in development, so we don’t recommend you run it on a production site. Consider setting up a test site to play with the new version.

There are two ways to test the WordPress 5.2 beta: try the WordPress Beta Tester plugin (you’ll want to select the “bleeding edge nightlies” option), or you can download the beta here (zip).

WordPress 5.2 is slated for release on April 30, and we need your help to get there! Thanks to the testing and feedback from everyone who tried beta 1, nearly 100 tickets have been closed since then. Here are the major changes and bug fixes:

  • We’ve added support for Emoji 12! 🪂
  • A brand-new wp_body_open() template tag (and corresponding wp_body_open action) will let themes (and plugins!) add content right after the <body> is opened (#12563).
  • Superfluous paragraph tags will no longer incorrectly appear in dynamic block content (#45495).
  • The Site Health screens have received several bug fixes, tweaks, and performance improvements.
  • Crash Protection no longer interrupts plugin editing (#46045).
  • Custom error handlers now load correctly (#46069).

Minimum PHP Version Update

As of WordPress 5.2 beta 2, the minimum PHP version that WordPress will require is 5.6.20. If you’re running an older version of PHP, we highly recommend updating it now, before WordPress 5.2 is officially released.

Developer Notes

WordPress 5.2 has lots of refinements to polish the developer experience. To keep up, subscribe to the Make WordPress Core blog and pay special attention to the developers notes for updates on those and other changes that could affect your products.

How to Help

Do you speak a language other than English? Help us translate WordPress into more than 100 languages!

If you think you’ve found a bug, you can post to the Alpha/Beta area in the support forums. We’d love to hear from you! If you’re comfortable writing a reproducible bug report, file one on WordPress Trac, where you can also find a list of known bugs.

The wonderful thing
about betas, is betas
are wonderful things.


ManageWP – Manage WordPress Sites from One Dashboard

ManageWP – Manage WordPress Sites from One Dashboard

Our sites use cookies and other tracking technologies to let us know how you interact with our services, to enrich your experience and the relevance of our advertising. This tool allows you to out out of such tracking. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

via ManageWP

March 28, 2019 at 12:37PM

How to Create a WordPress Membership Site with MemberPress & Elementor

How to Create a WordPress Membership Site with MemberPress & Elementor

The easiest way is to choose one of them and customize it to your needs. However, you can also start completely from scratch.

Once you have made your choice, you have two possibilities to integrate the MemberPress login form:

  1. Use the shortcode for the login page via the Elementor Shortcode widget.
  2. Input the MemberPress Login widget from inside Elementor (you can find it under WordPress or via search).

Again, you only have limited styling options with Elementor directly, so you need to use the custom CSS settings for that again. Once satisfied, click Publish. No need to set conditions, triggers or rules.

Now, you need to make the popup show up on your page. One way to do that is to edit your header template to include a Login button somewhere.

When you have done so, access its settings, find Link, choose Dynamic and then Action > Popup. After that, click the wrench symbol, pick Open Popup and find the popup you just created by name at the bottom.


via Elementor Blog

April 2, 2019 at 06:49AM

Minimum PHP Version update

WordPress 5.2 is targeted for release at the end of this month, and with it comes an update to the minimum required version of PHP. WordPress will now require a minimum of PHP 5.6.20.

Beginning in WordPress 5.1, users running PHP versions below 5.6 have had a notification in their dashboard that includes information to help them update PHP. Since then, the WordPress stats have shown an increase in users on more recent versions of PHP.

Screenshot of the "PHP Update Required" widget from the WordPress dashboard. Contains information about detecting an insecure version of PHP, how it affects your site, and a link for information on upgrading.
The dashboard widget users see if running an outdated version of PHP

Why You Should Update PHP

If your site is running on an unsupported version of PHP, the WordPress updater will not offer WordPress 5.2 to your site. If you attempt to update WordPress manually, that update will fail. To continue using the latest features of WordPress you must update to a newer version of PHP.

When updating to a new version of PHP, WordPress encourages updating to its recommended version, PHP 7.3. The PHP internals team has done a great job making its most recent version the fastest version of PHP yet. This means that updating will improve the speed of your site, both for you and your visitors.

This performance increase also means fewer servers are needed to host websites. Updating PHP isn’t just good for your site, it also means less energy is needed for the 1-in-3 sites that use WordPress, so it’s good for the planet.

How to Update PHP

If you need help updating to a new version of PHP, detailed documentation is available. This includes sample communication to send to your host for them to assist you. Many hosting companies have published information on how to update PHP that is specific for them.

5.6 now, but soon 7+

This is the first increase in PHP required version for WordPress since 2010, but may not be the only increase in 2019. The WordPress core team will monitor the adoption of the most recent versions of PHP with an eye towards making PHP 7+ the minimum version towards the end of the year.

Update PHP today, so you can update WordPress tomorrow!


What’s Coming in WordPress 5.2 (Features and Screenshots)

What’s Coming in WordPress 5.2 (Features and Screenshots)

WordPress 5.2 is expected to be released by the end of April 2019. We have been following the development and tested the first beta to try out new features that are on the way.

This release will bring improvements to the block editor, site health check, several bug fixes and minor enhancements.

In this article, we will show you what’s coming in WordPress 5.2 with features and screenshots.

What is coming in WordPress 5.2

Note: You can try out the beta version on your computer or on a staging environment by using the WordPress Beta Tester plugin.

WordPress 5.2 is still under development, which means some features may not make it to the final release.

That being said, let’s take a look at some of the upcoming features in WordPress 5.2.

Improved Fatal Error Protection in WordPress

The most common WordPress errors are usually fatal errors that stop users from accessing the admin dashboard.

Users are then required to undo changes using an FTP client or ask their hosting company for support.

WordPress 5.2 introduces a new recovery mode for site administrators. In case of a fatal error, you will see a message that ‘This site is experiencing technical difficulties’.

Technical difficulties error in WordPress 5.2

WordPress will then send an email to the admin email address with a special login link.

Using that link, you will be able to login to the WordPress admin area. After that, you can undo any changes that may have triggered the fatal error.

This feature will be a blessing for many beginners who find it quite difficult to fix such errors.

Block Editor Updates in WordPress 5.2

The WordPress block editor (Gutenberg) was introduced in WordPress 5.0. Since then there has been continuous development on the block editor to further improve it.

WordPress 5.2 will continue that with some new features and enhancements to the block editor.

Performance Improvements

The new WordPress block editor is much faster than the older classic editor. However, it could get slower when editing lengthier blog posts with tons of blocks.

WordPress 5.2 addressed that with significant performance improvements.

It will now shave 35% off the load time for massive posts. WordPress 5.2 will also cut the keypress time in half, which would make it feel way more responsive when you are typing.

Accessibility Improvements

The goal of WordPress is to democratize publishing and making the software accessible for all users. WordPress 5.2 will bring several accessibility improvements to the block editor.

  • The block editor will now support reduced motion settings in user’s browser.
  • The post URL slug will have better labeling and help text, which will make it easier to locate.
  • Block editor will have a clearer and consistent focus styling for keyboard navigating through landmarks.
  • WordPress 5.2 will also bring improved screen-reader experience with new speak messages. Existing speak messages are also improved to be clearer.

Introduction of New Blocks

WordPress 5.2 will also introduce the following new blocks in the default editor. Some of them were already available as Widgets, but now you can use them in posts and pages as well.

  • RSS block – It will allow you to easily fetch and display any RSS feed in your WordPress posts and pages.
  • Amazon Kindle embed block – Allows you to embed content from Amazon Kindle
  • Search block – Add the default WordPress search feature in your content.
  • Calendar block – Displays a calendar of your blog posts allowing users to click on a date to view posts published on that day.
  • Tag Cloud block – Displays the tag cloud in your content.

A New Block Manager Tool

By default, the block editor comes with several default blocks. You also have plugins and themes adding their own blocks as well.

However, the reality is that you’ll probably never use all those blocks. Most users usually stick to a handful of blocks for writing all their content.

WordPress 5.2 will introduce a new block management tool, which will allow you to hide blocks that you don’t want to use.

Launching the new block manager in WordPress 5.2

The block manager will list all the blocks that you have available on your site. You can simply uncheck the blocks that you don’t want to use.

The new block manager in WordPress

The Minimum PHP Version Requirement

WordPress is used by millions of people from all over the world, using different hosting companies, and hosting environments.

This is why WordPress still supports some older PHP versions, which is a bit problematic. Users may not even realize that they can improve the performance of their website by using a newer PHP version.

WordPress 5.2 will set the current minimum required PHP version to 5.6, which is still old (current stable PHP version is 7.3.2). The goal is to gradually increase the minimum required PHP version with future releases.

Users on the older versions of PHP will see a notification, that they are using an older PHP version and need to update it.

PHP version notice in WordPress 5.2 beta

Under The Hood Improvements in WordPress 5.2

These are the changes in WordPress 5.2 which will mostly affect developers.

Users will be able to provide a log file path when adding WP_DEBUG_LOG in wp-config.php file. #18391.

Plugins will be able to specify the minimum required PHP version. #40934

Dashicons, the default icon font used for the WordPress admin area will have 25 new icons to use. #41074

We hope this article gave you a glimpse of what’s coming in WordPress 5.2. Let us know which features you find interesting and what new features you would like to see in the future.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post What’s Coming in WordPress 5.2 (Features and Screenshots) appeared first on WPBeginner.


via WPBeginner

April 1, 2019 at 05:11AM

Python Functions

Python Functions

Python Functions

A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.

A function can return data as a result.

Creating a Function

In Python a function is defined using the def


def my_function():
  print("Hello from a function")

Calling a Function

To call a function, use the function name followed by parenthesis:


def my_function():
  print("Hello from a function")


Run example »


Information can be passed to functions as parameter.

Parameters are specified after the function name, inside the parentheses.
You can add as many parameters as you want, just separate them with a comma.

The following example has a function with one parameter (fname).
When the function is called, we pass along a first name,
which is used inside the function to print the full name:


def my_function(fname):
  print(fname + " Refsnes")


Run example »

Default Parameter Value

The following example shows how to use a default parameter value.

If we call the function without parameter, it uses the default value:


def my_function(country = "Norway"):
  print("I am from " +


Run example »

Return Values

To let a function return a value, use the return


def my_function(x):
  return 5 * x


Run example »


Python also accepts function recursion, which means a defined function can call itself.

Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result.

The developer should be very careful with recursion as it can be quite easy to slip into writing a function which never terminates, or one that uses excess amounts of memory or processor power. However, when written correctly recursion can be a very efficient and mathematically-elegant approach to programming.

In this example, tri_recursion() is a function that we have defined to call itself ("recurse"). We use the k variable as the data, which decrements (-1) every time we recurse. The recursion ends when the condition is not greater than 0 (i.e. when it is 0).

To a new developer it can take some time to work out how exactly this works, best way to find out is by testing and modifying it.


Recursion Example

def tri_recursion(k):
result = k+tri_recursion(k-1)
result = 0
return result

print("\n\nRecursion Example Results")

Run example »

via W3Schools Online Web Tutorials

March 31, 2019 at 08:50PM