Class FeaturedImageResolver

java.lang.Object
com.norconex.crawler.core.event.listeners.CrawlerLifeCycleListener
com.norconex.crawler.web.doc.operations.image.impl.FeaturedImageResolver
All Implemented Interfaces:
Configurable<FeaturedImageResolverConfig>, EventListener<Event>, DocumentConsumer, EventListener, BiConsumer<Fetcher,Doc>, Consumer<Event>

public class FeaturedImageResolver extends CrawlerLifeCycleListener implements DocumentConsumer, Configurable<FeaturedImageResolverConfig>

Document processor that extract the "main" image from HTML pages. Since HTML is expected, this class should only be used as a pre-import processor. It is possible for this processor to not find any image.

Finding the image

By default this class will get the first image (<img>) matching the minimum size. You can specify you want the largest of all matching ones instead. In addition, if you know your images to be defined in a special way (e.g., all share the same CSS class), then you can use the "domSelector" to limit to one or a few images. See JSoup selector-syntax for how to build the "domSelector".

Storing the image

When identified, the featured image can be stored either on local disk, or as a metadata field in Base64 format, or simply as a URL pointing to its remote location. See FeaturedImageResolverConfig for details.

Since:
2.8.0