There's one other gotcha in this, otherwise at a first glance this looks pretty good.
In the layout the regex matches array is also used for Pinterest sharing (that's what the Always run this preg_match as the results are also used in the layout comment is referring to), so the layout will need to be changed to use your new $imageOg variable instead of the $matches array since that won't always be defined now.
There's one other gotcha in this, otherwise at a first glance this looks pretty good.
In the layout the regex matches array is also used for Pinterest sharing (that's what the
Always run this preg_match as the results are also used in the layout
comment is referring to), so the layout will need to be changed to use your new$imageOg
variable instead of the$matches
array since that won't always be defined now.