I’m developing a theme that’s dependent upon there being post thumbnails of a certain size for each post. But, if the client forgets to add a thumbnail or doesn’t have one for a post, I don’t want it to break the site’s layout.
I created a function called be_no_thumbnail($size). When you run that function (with an appropriate size) it will generate a blank image of that size.
This is designed to work with the image sizes defined in Settings > Media (thumbnail, small, medium, large). You’d need a different approach for custom image sizes as their dimensions aren’t stored in the same database fields.
Here’s the function:
And here’s how I use it: