-
Notifications
You must be signed in to change notification settings - Fork 107
Attributes option explained
Here we will talk about the attributes
option. By default LinkThumbnailer set this option to the following value:
config.attributes = [:title, :images, :description, :videos, :favicon]
Each element of the above array is used to tell LinkThumbnailer what to look for on a given website. Here we want LinkThumbnailer to find:
- A
title
for the given website -
images
for the given website if any - A
description
for the given website -
videos
for the given website if any - The
favicon
LinkThumbnailer will do its best to fulfill your requirements by trying to find those attributes using its scrapers
. Scrapers are plain old ruby class build inside LinkThumbnailer used to parse the given website HTML content. Currently there are 2 type of scrapers that use 2 different techniques:
- OpenGraph scraper that will use the OpenGraph protocol
- Homemade custom scraper that will parse the raw HTML
In order for LinkThumbnailer to find a title, it will look at (in order):
- the
og:title
opengraph attribute - the
title
html attribute
In order for LinkThumbnailer to find images, it will look at (in order):
- the
og:images
opengraph attribute(s) (LinkThumbnailer can handle multipleog:images
attributes) - the
img
html attribute(s)
In order for LinkThumbnailer to find videos, it will look at (in order):
- the
og:videos
opengraph attributes(s) (LinkThumbnailer can handle multipleog:videos
attributes)
In order for LinkThumbnailer to find a description, it will look at (in order):
- the
og:description
opengraph attribute - the
p,td
css selectors and will sort them using graders
Any link
tag in the header that includes the icon
string:
<link rel="icon" type="image/x-icon" href="http://foo.com/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="http://foo.com/favicon.ico">
<link rel="icon shortcut" type="image/x-icon" href="http://foo.com/favicon.ico">
All the above will match.
Please ask if you want LinkThumbnailer to handle more attributes.