Documentation ¶
Index ¶
- func EnforceURLSchema(pageURL string, imageURL string) string
- type GetImageNodeInfoBatchOptions
- type GetImageNodeInfoOptions
- type ImageNode
- type ImageNodeInfo
- func DetermineThumbnail(imageNodesWithInfo []*ImageNodeInfo) (*ImageNodeInfo, error)
- func GetImageNodeInfo(imageNode ImageNode, options ...GetImageNodeInfoOptions) (*ImageNodeInfo, error)
- func GetImageNodeInfoBatch(imageNodes []ImageNode, options ...GetImageNodeInfoBatchOptions) ([]*ImageNodeInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnforceURLSchema ¶
EnforceURLSchema enforces the proper URL format to allow requests to be made to retrieve them. Images embeded in HTML image elements are often missing the schema prefix. This is used by GetImageNodeInfo to ensure that the URL is valid before making a request for the image resource.
Types ¶
type GetImageNodeInfoBatchOptions ¶
type GetImageNodeInfoBatchOptions struct { GetImageNodeInfoOptions RequireAll bool }
GetImageNodeInfoBatchOptions represents the configuration used by GetImageNodeInfoBatch. Default for RequireAll is false.
type GetImageNodeInfoOptions ¶
type GetImageNodeInfoOptions struct {
ScrapeImages bool
}
GetImageNodeInfoOptions represents the configuration used by GetImageNodeInfo. Default for ScrapeImages is false.
type ImageNode ¶
ImageNode represents information relating to HTML images elements discovered on the requested URLs.
func GetImageNodes ¶
GetImageNodes returns an []ImageNode containing the names, alt tags, URLs and whether an image is from an OpenGraph image meta tag.
type ImageNodeInfo ¶
ImageNodeInfo represents information relating to image elements discovered on the requested URLs with additional useful information. Image is only populated if ScrapeImages is set to true in ImageNodeInfoOptions or ImageNodeInfoBatchOptions.
func DetermineThumbnail ¶
func DetermineThumbnail(imageNodesWithInfo []*ImageNodeInfo) (*ImageNodeInfo, error)
DetermineThumbnail returns the *ImageNodeInfo for the best thumbnail from a []*ImageNodeInfo. The *ImageNodeInfo will also have the image itself in the Image property if ScrapeImages is set to true in GetImageNodeInfoBatchOptions that was passed into GetImageNodeInfoBatch. error is returned if the supplied []*ImageNodeInfo is empty.
func GetImageNodeInfo ¶
func GetImageNodeInfo(imageNode ImageNode, options ...GetImageNodeInfoOptions) (*ImageNodeInfo, error)
GetImageNodeInfo takes an ImageNode and returns an *ImageNodeInfo struct with additional properties received after loading and analysing the image itself. options is an optional GetImageNodeInfoOptions struct to specify whether to keep images in the returned ImageNodeInfo struct, default of which is false.
func GetImageNodeInfoBatch ¶
func GetImageNodeInfoBatch(imageNodes []ImageNode, options ...GetImageNodeInfoBatchOptions) ([]*ImageNodeInfo, error)
GetImageNodeInfoBatch does the same thing as GetImageNodeInfo, but takes an []ImageNode instead to allow you to get an []ImageNodeInfo back after processing them in batch. options is an optional GetImageNodeInfoBatch options struct to specify whether to keep images in the returned ImageNodeInfo structs, default of which is false, and whether to require all image requests to complete successfully, default of which is also false. Refer to struct type GetImageNodeInfoBatchOptions for more information.