• Skip to main content

Victor Font Consulting Group, LLC

Strategic IT Solutions for Complex Organizations

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network

Add Custom Image Sizes to Media Library

posted on October 25, 2015

Media Library Custom Image Size

When you upload an image to the WordPress Media Library, WordPress creates any number of new images either scaled to or cropped from your original image. The number of images that are created are determined by the WordPress defaults, your theme's configuration, or plugins. This article focuses on the default WordPress settings and how you can add new image sizes to the media library attachment display settings.

Post Thumbnails

Post thumbnails (now called featured images) were introduced in WordPress Version 2.9. A featured image is the representative image for a Post, Page, or Custom Post Type. The display of a featured image is controlled entirely by the site's theme. The theme has to specifically declare its support for featured images by using the following code in functions.php.

Thumbnail Sizes

When you upload an image, WordPress creates three default thumbnails in addition to the original image. The default thumbnails are Thumbnail, Medium, and Large. Their sizes are:

  • Thumbnail—default 150px x 150px max
  • Medium resolution —default 300px x 300px max
  • Large resolution—default 640px x 640px max
  • Original image resolution—unmodified

The default sizes of these images can be changed through the Admin/Settings/Media page:

WordPress Media Settings

If you click on the screen print above, you'll see that we've redefined the Large image size to be 1024px x 1024px for this site. Also if you check "Crop thumbnail to exact dimensions (normally thumbnails are proportional)", the thumbnail images will be cropped to the exact dimensions specified whenever possible.

Add Custom Image Size

There are two steps that need to be taken to create a new image size to have it appear in the media library attachment display settings. First, you have to register a new image size. This is done with the WordPress add_image_size function. The syntax is:

The second step is to apply the new image to the image_size_names_choose filter.

Add the code below to your functions.php and you'll have a new image size in your media library attachment display settings.

  • 15shares
  • Facebook0
  • Twitter1
  • Pinterest0
  • LinkedIn14
  • Print
  • SMS0

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

 
We only use analytical cookies on our website that allow us to recognize and count the number of visitors, but they do not identify you individually. They help us to improve the way our website works. By clicking Accept you, agree to cookies being used in accordance with our Cookie Policy.