• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero Blog

NameHero Blog

Web Hosting Tips & Resources From NameHero

  • Hosting
    • Web Hosting
    • VPS Hosting
    • WordPress Hosting
    • WooCommerce Hosting
  • Reseller
  • Enterprise
  • Domains
  • Account
  • Blog Home
  • Categories

How To Add Custom Image Dimensions To WordPress Dropdowns

Bhagwad Park

Published on: January 28, 2019

Categories: WordPress 0

For some of us who write a lot on WordPress, a few extra seconds shaved off a routine task can be huge, especially when we have to repeat those things multiple times in a single post. For example, sizing images is a big one.

Using Custom Image Dimensions in WordPress

Every website’s layout is different, and each site owner needs to determine the standard dimensions of images that they want on their page. I’m not talking about the image size, since that depends on the file – I’m talking about the actual size that’s displayed on the screen.

By default, WordPress has the following custom sizes:

  1. Thumbnail
  2. Medium
  3. Large
  4. Full Size

These are self-explanatory. However, chances are that none of these are ideal for your article. You most likely need a custom image size. In the old classic WordPress editor, you had to go to the image settings, choose the “Custom Size” item from the drop-down box, and enter your custom dimensions as shown here:

Even More Difficult in the Classic Editor

Needless to say, this was annoying as hell when you had to do it multiple times per article.

Choosing Custom Dimensions in Gutenberg

With Gutenberg, the process got a bit smoother, but still not ideal. Now the process of adding an image is itself simplified – just type slash (/) and start typing “image”, and you can upload/choose an image from the gallery right then and there.

Also, when you select the image block, you can choose the properties on the right-hand side like this:

Limited List of Image Sizes

Here we have the same dropdown box with the standard image sizes explained above. However, you can directly type in a custom image dimension in a box below without specifically needing to select “Custom Size”.

Even more, you can manually resize the image by dragging the borders to the dimension you want. While it’s easier than manually entering the dimensions, it’s also a bit imprecise. If you have a bunch of writers on your site, you probably want to standardize the images that they use on the site. It’s not a good idea to just leave it to their discretion.

So here’s how to add a custom image dimension to the drop-down list for easy selection.

Adding a Custom Image Dimension to the Dropdown

Add the following code to your functions.php file, or to the plugin where you place your custom PHP code:

function use_new_image_size() {
    if ( function_exists( 'add_image_size' ) ) {
        add_image_size( 'new-image', 550, 0, false );
    }
}
add_action( 'after_setup_theme', 'use_new_image_size' );

function create_custom_image_size($sizes){
    $custom_sizes = array(
    'new-image' => '550 Image'
    );
    return array_merge( $sizes, $custom_sizes );
}
add_filter('image_size_names_choose', 'create_custom_image_size');

If you don’t know how to do this, here’s a tutorial from NameHero’s knowledgebase on how to add custom code to WordPress. It’s a useful skill!

In the above code, replace the dimensions of the image with the ones you want in the following line:

add_image_size( 'new-image', 550, 0, false );

So here, I’ve sent the image width as “550” pixels. Use the value that makes sense for your site. Also, in this line:

'new-image' => '550 Image'

Choose the label that will appear in the dropdown box for easy identification. Once you’ve saved your changes, a new item should appear in the dropdown list of image sizes like this:

Custom Image Added to WordPress Gutenberg

And you’re done! Now if you select the new entry, your pre-defined image size will automatically be selected and applied to the image. It’s a great shortcut to save you lots of time, and it works just as well with the new Gutenberg WordPress editor too!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!

Most Popular Posts

Speed up your site: solving the WordPress slowdown

NameHero’s Recommended WordPress Plugin and Theme Setup (2023)

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • Website Performance
  • Web Hosting
  • Resellers
  • Website Development
  • Website Security
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • Domains
Help & Support
  • NameHero Blog
  • Knowledgebase
  • Announcements
  • Affiliates
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2023 NameHero, LLC. All rights reserved.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA