This is a real quick tech note because I KNOW I’ll come back to it again and again.

I’ve been working a lot with the WordPress Customizer API today and in the last few weeks. Today I wanted to add a few image options. But the lack of really good documentation around the control classes is a problem. In the absence of good documentation, the obvious class to use for images is WP_Customize_Image_Control.

HOWEVER, this control saves the URL of an image, which isn’t great, because you can only get back the original size of the image. If we had the post ID of the attachment we could do all sorts of cool things; even make use of the new wp_get_attachment_image_srcset() function to generate a responsive image tag.

And there IS a way. You just use WP_Customize_Media_Control instead.