<?php /* * Plugin Name: Replace og:image .avif to .jpg * Description: Replaces og:image URLs ending in -jpg.avif with .jpg in the page output. */ add_action( 'template_redirect', function() { ob_start( 'joost_replace_og_image_avif_with_jpg' ); } ); function joost_replace_og_image_avif_with_jpg( $buffer ) { // Replace "-jpg.avif" with ".jpg" in og:image meta tags. return preg_replace('/(<meta\s+property="og:image"\s+content="[^"]+)-jpg\.avif(")/i', '$1.jpg$2', $buffer); }