/**
     *
     * @param HttpResource $asset 
     */
    public function render($asset)
    {
        if (! $asset->is_image())
        {
            return false;
        }
        
        global $THEME;
        $url = $asset->url();
        $title = $asset->title();
        $title = $title ? $title : $asset->name();
        
        $size = (int) $asset->config('size');
        $size = (24 <= $size && $size <= 800) ? $size : 300;
        
        $embed = <<<EOT
        <div style="text-align:center"><a href="$url"><img src="{$url}" width="$size" alt="{$title}" title="{$title}"></a></div>
EOT;

        $result = array();
        $result[self::URL] = $url;
        $result[self::EMBED_SNIPPET] = $embed;
        $result[self::TITLE] = $title;
        $result[self::THUMBNAIL] = $url;
        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;
    }
    /**
     *
     * @param HttpResource $asset 
     */
    public function render($asset)
    {
        
        if ($asset->url_match('gmodules.com/ig/') && $asset->url_param('url') != false)
        {
            $url = $asset->url();
            $title = $asset->url_param('title');
            $title = ($title == '__MSG_title__') ? '' : $title;
            
            $embed = <<<EOT
                <script src="$url"></script>
EOT;
            
            $result = array();
            $result[self::EMBED_SNIPPET] = $embed;
            $result[self::TITLE] = $title;
            return $result;
        }

        if (!$asset->is_gadget())
        {
            $url = $asset->url();

            if (!$asset->url_match('google.com/ig/directory'))
            {
                return false;
            }
            if (!$asset->url_match('type=gadgets'))
            {
                return false;
            }

            $url = $asset->url_param('url');
            if (empty($url))
            {
                return false;
            }
            $asset = new HttpResource($url);
            if (!$asset->is_gadget())
            {
                return false;
            }
        }

        $url = $asset->url();
        if (strpos($url, 'http') !== 0)
        {
            $url = "http://$url";
        }
        $url = urlencode($url);
        $title = $asset->title();
        $title = $title ? $title : $asset->name();
        
        $size = (int) $asset->config('size');
        $size = (24 <= $size && $size <= 800) ? $size : 300;

        $embed = <<<EOT
        <script src="//www.gmodules.com/ig/ifr?url=$url&amp;w=$size&amp;output=js"></script>
EOT;

        $result = array();
        $result[self::EMBED_SNIPPET] = $embed;
        $result[self::TITLE] = $title;
        return $result;
    }
    /**
     * @param HttpResource $asset
     * @return array
     */
    protected function render_image($asset)
    {
        $size = (int) $asset->config('size');
        $size = (24 <= $size && $size <= 800) ? $size : 300;

        $title = $data['title'];
        $width = $data['width'];
        $height = $data['height'];
        $ratio = $height / $width;
        $base = min($size, $width);
        $width = $base;
        $height = $ratio * $base;

        $url = $data['url'];

        $embed = <<<EOT
        <a href="$url"><img src="{$url}" width="{$width}" height="{$height} "alt="{$title}" title="{$title}"></a>
EOT;
    }