• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

How to add additional image sizes to the WordPress image and gallery dropdown

Find out in this tutorial how to use custom image sizes in WordPress image and gallery block using code.

In the previous tutorial you saw how to find out all the image sizes that a WordPress installation has.

But you probably noticed that, of all those sizes, only a few of them are available when you use the image or gallery block.

Usually only 3 are shown:

  • Thumbnail
  • Medium
  • Large
default-image-sizes-block-image-WordPress
Sizes displayed by default in the image block

But you may be interested in displaying some of the other sizes as well, even one that you have custom registered.

custom-image-sizes-block-image-WordPress
Custom image sizes in WordPress image block

That’s why with this tutorial you are going to get a custom image size to appear in the dropdown of the WordPress image and gallery blocks as well.

Let’s take a look at it:

Snippet to use custom image sizes in WordPress image block

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 839 code snippets of this website, login or subscribe here.

With this code you get to add 3 custom sizes to the dropdown, specifically:

  • gb-block-post-grid-landscape -> GB Grid Landscape
  • gb-block-post-grid-square -> GB Grid Square
  • genesis-singular-images -> Genesis Singular
custom-image-sizes-block-image-WordPress
Custom image sizes in WordPress image block

Of course, this is just an example. You can use any of the image sizes you get with this previous tutorial to add the ones you are interested into the dropdown.

Also, you can give any name you want to each of the sizes. Instead of “GB Grid Square” you can call it “Genesis Blocks Square” or whatever you prefer. 😉

Conclusions

Now you know how to add custom image sizes to the image or gallery block in WordPress.

If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.

Benefits of being a subscriber. 🙂

PHP WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?