/** * Prebuilds oembeds for all urls in a given text * * @param type $text */ public static function preload($text) { preg_replace_callback('/http(.*?)(\\s|$)/i', function ($match) { $url = $match[0]; // Already looked up? if (UrlOembed::findOne(['url' => $url]) !== null) { return; } UrlOembed::loadUrl($url); }, $text); }