How to Add custom attribute to image using the_post_thumbnail

How to Add custom attribute to image using the_post_thumbnail

How to Add custom attribute to image using the_post_thumbnail Sometimes you will need to add a custom attribute to an image. This is very easy to do using the_post_thumbnail() function. The following snippet will add the custom attribute of 'itemprop="image" to your images but you can change that to nearly anything including class, alt, title etc.