/** * * @param HttpResource $asset */ public function render($asset) { global $THEME; $url = $asset->url(); $title = $asset->title(); $title = $title ? $title : $asset->name(); $description = $asset->get_meta('description'); $description = $description; $keywords = $asset->get_meta('keywords'); $image_src = $asset->get_link('rel', 'image_src'); $image_src = $image_src ? $image_src['href'] : false; if (empty($image_src)) { $image_src = $this->get_icon($asset); } $icon = $this->get_icon($asset); $image_src = $asset->canonic_url($image_src); $icon = $asset->canonic_url($icon); $embed = <<<EOT <a href="$url"> <img src="{$image_src}" alt="{$title}" title="{$title}" style="float:left; margin-right:5px; margin-bottom:5px; " > </a> $description <span style="clear:both;"></span> EOT; $result = array(); $result[self::EMBED_SNIPPET] = $embed; $result[self::TITLE] = $title; $result[self::THUMBNAIL] = $image_src; $result[self::DESCRIPTION] = $description; $result[self::ICON] = $icon; $result[self::TAGS] = $keywords; return $result; }
/** * * @param HttpResource $asset */ public function render($asset) { $link = $asset->get_link('type', 'application/json+oembed'); if (empty($link)) { return false; } $width = (int) $asset->config('size'); $width = (24 <= $width && $width <= 800) ? $width : 300; $href = $link['href']; $data = HttpResource::fetch_json("$href&maxwidth=$width"); //&maxheight=$height if (empty($data)) { return false; } $data['title'] = isset($data['title']) ? $data['title'] : ''; $data['width'] = isset($data['width']) ? intval($data['width']) : ''; $data['height'] = isset($data['height']) ? intval($data['height']) : ''; $type = $data['type']; $f = array($this, "render_$type"); if (is_callable($f)) { $result = call_user_func($f, $asset, $data); } else { $result = array(); } $result[self::THUMBNAIL] = isset($data['thumbnail_url']) ? $data['thumbnail_url'] : ''; $result[self::TITLE] = isset($data['title']) ? $data['title'] : ''; return $result; }