public static function getEmbedFromLink($link, $width = 0, $height = 0) { $matches = array(); if (preg_match("/http:\\/\\/www\\.youtube\\.com\\/watch\\?v\\=(?<id>[\\w_-]+)/", $link, $matches)) { return Stuffpress_Services_Webparse::getEmbedYoutube($matches['id'], $width, $height); } else { if (preg_match("/http:\\/\\/vimeo\\.com\\/(?<id>\\w+)/", $link, $matches)) { return Stuffpress_Services_Webparse::getEmbedVimeo($matches['id'], $width, $height); } else { return false; } } }
public function getImageUrl($size = ImageItem::SIZE_MEDIUM) { if ($this->getType() == SourceItem::VIDEO_TYPE) { return Stuffpress_Services_Webparse::getImageFromEmbed($this->_data['embed'], $size); } else { if ($this->getType() != SourceItem::IMAGE_TYPE) { return false; } } // Get the file key $key = $this->_data['file']; // Get the file $files = new Files(); $file = $files->getFileFromKey($key); $name = urlencode($file['name']); // Get the root url $config = Zend_Registry::get("configuration"); $secure = Zend_Registry::get("secure"); $host = $config->web->host; $path = $config->web->path; $proto = $secure ? "https" : "http"; $url = trim("{$proto}://{$host}{$path}", '/'); switch ($size) { case ImageItem::SIZE_THUMBNAIL: return "{$url}/image/thumbnail/{$key}/{$name}"; break; case ImageItem::SIZE_SMALL: return "{$url}/image/small/{$key}/{$name}"; break; case ImageItem::SIZE_MEDIUM: return "{$url}/image/medium/{$key}/{$name}"; break; case ImageItem::SIZE_LARGE: return "{$url}/image/large/{$key}/{$name}"; break; case ImageItem::SIZE_ORIGINAL: return false; break; } }
public function videoAction() { $this->common(); $this->tinyMCE(); if (isset($this->view->form)) { return; } if ($this->_bookmarklet) { $source = StuffpressModel::forUser($this->_application->user->id); $embed = Stuffpress_Services_Webparse::getEmbedFromLink($this->_bkurl, 160, 100); $this->view->form = $this->getFormVideo($source->getID(), 0, $this->_bktitle, $this->_bktext, $embed); } else { $this->view->form = $this->getForm('video'); } }
public function getImageUrl($size = ImageItem::SIZE_MEDIUM) { if ($this->getType() == SourceItem::VIDEO_TYPE) { return Stuffpress_Services_Webparse::getImageFromEmbed($this->_data['video_player'], $size); } $matches = array(); preg_match("/(?<base>.*)_\\w*\\.(?<ext>\\w*)\$/", $this->_data['photo_url'], $matches); switch ($size) { case ImageItem::SIZE_THUMBNAIL: return "{$matches['base']}_75sq.{$matches['ext']}"; break; case ImageItem::SIZE_SMALL: return "{$matches['base']}_250.{$matches['ext']}"; break; case ImageItem::SIZE_MEDIUM: return $this->_data['photo_url']; break; case ImageItem::SIZE_LARGE: return $this->_data['photo_url']; break; case ImageItem::SIZE_ORIGINAL: return false; break; } }