/** * Gets the image preview (virtual field) * @return string|null * @uses MeTools\Utility\Youtube::getId() * @uses MeTools\Utility\Youtube::getPreview() */ protected function _getPreview() { if (empty($this->_properties['text'])) { return null; } //Checks for the first image in the text preg_match('#<\\s*img [^\\>]*src\\s*=\\s*(["\'])(.*?)\\1#im', $this->_properties['text'], $matches); if (!empty($matches[2])) { return Router::url($matches[2], true); } //Checks for a YouTube video and its preview preg_match('/\\[youtube](.+?)\\[\\/youtube]/', $this->_properties['text'], $matches); if (!empty($matches[1])) { return Youtube::getPreview(isUrl($matches[1]) ? Youtube::getId($matches[1]) : $matches[1]); } return null; }