How to add Width and Height attributes on Post Thumbnail Medium size?
-
Hi, I need some clue here. I hope someone can point me to the right direction.
I am displaying featured images with medium size on feed pages. I added
<?php the_post_thumbnail('medium'); ?>
on the loop template file.And, for schema.org markup, I also added itemprop image attribute to the featured images with below code on my theme’s functions.php.
add_filter('wp_get_attachment_image_attributes', 'ipwp_img_attr', 10, 2); function ipwp_img_attr($attr) { $attr['itemprop'] = 'image'; return $attr; }
The result is:
<img src=”https://my-site.com/wp-content/uploads/YYYY/MM/my-image.png” class=”attachment-medium wp-post-image” alt=”My Image” itemprop=”image”>It’s missing width and height attributes. I need them to score higher on page speed tests.
Anyone knows how to add the width and height attributes there?
- The topic ‘How to add Width and Height attributes on Post Thumbnail Medium size?’ is closed to new replies.