Fixing an issue with og:image and Featured Images

Over the past month, I've been putting some extra effort into updating the VegasGeek site. As they say, the cobbler's kids have no shoes. Well, the web developer's website is the last to receive updates.

One of the first things I noticed was the preview image being used on social media when I shared the new Email Authenticity Guard page, rather than using the featured image I had set, it was using a default image I had set years back. I was confused, to say the least.

I won't bore you with the research, but what I found was a known bug in the Yoast SEO plugin where it's possible that an update to the featured image may not always result in the og:image tag being updated to use the new image. After spending way too much time digging into what is causing the issue and coming up empty-handed, I did what I often do in these situations; I wrote a little plugin to fix the issue.

OG Image Fixer for Yoast

The Yoast Developer Portal has some great information about the hooks, filters, and APIs available to work with the plugin. I ended up using 4 of the available filters to modify the image URL, width, height, and mime type for the image on any page or post where a featured image is set.

I have not done extensive testing with portions of the site like archives, custom post types, etc. But for pages & posts, if you find your og:image isn't updating to use the featured image you have set, this plugin should solve that issue for you.

You can download the plugin from Github. If you run into any issues or have suggestions for improvements to the plugin, please open an issue on the Github repo.