Output og:image:url if the og:image exists
I found a module that did something similar and just changed a bit:

function remove_generator_page_attachments_alter(array &amp;$attachments) {

  $has_image = false;
  $index_to_remove = -1;

  foreach ($attachments['#attached']['html_head'] as $key =&gt; $attachment) {

    if ($attachment[1] == 'og_image_url_0' || $attachment[1] == 'og_image_url') {
      $index_to_remove = $key;
    }

    if ($attachment[1] == 'og_image_0' || $attachment[1] == 'og_image') {
      $has_image = true;
    }
  }

  if($has_image &amp;&amp; $index_to_remove &gt; -1) {
    unset($attachments['#attached']['html_head'][$index_to_remove]);
  }

}