Skip to content

Intermediate images

Intermediate images are a defined array of alternate sizes for an image that is uploaded to a site’s WordPress media library. The default sizes in this array are thumbnailmedium, and large. The pixel dimensions for each of these default sizes can be defined in the Settings –> Media screen of the WordPress Admin dashboard. Additional intermediate image sizes can be registered with add_image_size().

On most platforms, when an image is uploaded to WordPress, intermediate image sizes are generated as separate files (e.g., image-150x150.jpg, image-300x300.jpg). On the VIP Platform, separate files are not created for intermediate images. Instead, the intermediate size of an image is dynamically generated at the time of a request (e.g., image.jpg?w=150&h=150&crop=1, image.jpg?w=300&h=300&crop=1), and then cached on the edge cache servers. Only the full size version of the originally uploaded file is stored in the site’s /uploads/ directory.

Avoid including intermediate images when preparing content for importing media to an application. This can reduce the size of the exported content (up to 95% of the size can be saved), and increase the speed of the import.

Using image sizes

To output an image at a desired intermediate image size, pass the name of a registered image size to the_post_thumbnail(). For example, a site registers a new custom image size named small-square in the theme’s functions.phpadd_image_size( 'small-square', 100, 100, true );.

A template in the site’s WordPress theme can use the_post_thumbnail( 'small-square' ); to output an image located within /uploads/ at the small-square size. The src URL where the image is output at the small-square size will look similar to: https://example.com/uploads/2022/12/image.jpg?crop=100,100,100,100&resize=100,100

Last updated: December 29, 2022