Repository navigation
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
titlefor the given website -
imagesfor the given website if any - A
descriptionfor the given website -
videosfor 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:titleopengraph attribute - the
titlehtml attribute
In order for LinkThumbnailer to find images, it will look at (in order):
- the
og:imagesopengraph attribute(s) (LinkThumbnailer can handle multipleog:imagesattributes) - the
imghtml attribute(s)
In order for LinkThumbnailer to find videos, it will look at (in order):
- the
og:videosopengraph attributes(s) (LinkThumbnailer can handle multipleog:videosattributes)
In order for LinkThumbnailer to find a description, it will look at (in order):
- the
og:descriptionopengraph attribute - the
p,tdcss 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.