Class FeaturedImageResolver
- All Implemented Interfaces:
Configurable<FeaturedImageResolverConfig>,EventListener<Event>,DocumentConsumer,EventListener,BiConsumer<Fetcher,,Doc> Consumer<Event>
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
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidProcesses a document.protected booleanbooleaninthashCode()protected voidonCrawlerCrawlBegin(CrawlerEvent event) toString()Methods inherited from class com.norconex.crawler.core.event.listeners.CrawlerLifeCycleListener
accept, onCrawlerCleanBegin, onCrawlerCleanEnd, onCrawlerCrawlEnd, onCrawlerError, onCrawlerEvent, onCrawlerStopBegin, onCrawlerStopEndMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.BiConsumer
andThen
-
Constructor Details
-
FeaturedImageResolver
public FeaturedImageResolver()
-
-
Method Details
-
onCrawlerCrawlBegin
- Overrides:
onCrawlerCrawlBeginin classCrawlerLifeCycleListener
-
accept
Description copied from interface:DocumentConsumerProcesses a document.- Specified by:
acceptin interfaceBiConsumer<Fetcher,Doc> - Specified by:
acceptin interfaceDocumentConsumer- Parameters:
fetcher- document fetcherdoc- crawl document
-
equals
- Overrides:
equalsin classCrawlerLifeCycleListener
-
canEqual
- Overrides:
canEqualin classCrawlerLifeCycleListener
-
hashCode
public int hashCode()- Overrides:
hashCodein classCrawlerLifeCycleListener
-
toString
- Overrides:
toStringin classCrawlerLifeCycleListener
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<FeaturedImageResolverConfig>
-