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.



the_post_thumbnail( 'thumbnail', array('itemprop'=>'image') );

( WordPress codex functions, hooks, in this snippet. )


Optimization WordPress Plugins & Solutions by W3 EDGE