add_image_size() for specific Post Types

There is no way to base the image sizes on the post type, as images are not yet attached to a post when you upload them and the intermediate image sizes are created (when you just add them via “New Media” they are not even attached to any post at all).

However, I recently created two plugins that together will do what you want. Virtual intermediate images will intercept the creation of the intermediate image sizes: they will not be created on disk, but still exist in the metadata array. This makes WordPress think they exist so you can use them like normal images. The companion plugin, On-Demand Resizer will create missing image sizes when they are requested. The first time the image is requested it is created, all subsequent requests will just be served the newly created image.

These plugins need a rewrite before I put them in the WordPress plugin directory, but they should be safe. Or at least have TODO comments where they are unsafe.

Leave a Comment