Created
July 11, 2014 06:30
-
-
Save cergey-obr/9d03238ce9a89bd8cf33 to your computer and use it in GitHub Desktop.
Получение превьюшки для видео
$id - id видео
$field - название поля
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getYoutubePreview($id, $field) { | |
$hierarchy = umiHierarchy::getInstance(); | |
$video = $hierarchy->getElement($id); | |
if ($video instanceof umiHierarchyElement) { | |
if ($video->$field instanceof umiImageFile) { // если изображение уже записано | |
return substr($video->$field->getFilePath(), 1); | |
} else { // если поле пустое | |
$link = $video->youtube; | |
if ($youtube_id = $this->getYouTubeIdFromURL($link)) { // получаем изображение с сервера youtube | |
$photo = $this->getYouTubeImg($youtube_id); | |
$video->setValue($field, '.'.$photo); | |
$video->commit(); | |
return $photo; | |
} | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment