MCPcopy Index your code
hub / github.com/unclecode/crawl4ai / is_valid_image

Function is_valid_image

crawl4ai/utils.py:531–541  ·  view source on GitHub ↗
(img, parent, parent_classes)

Source from the content-addressed store, hash-verified

529 def process_image(img, url, index, total_images):
530 #Check if an image has valid display and inside undesired html elements
531 def is_valid_image(img, parent, parent_classes):
532 style = img.get('style', '')
533 src = img.get('src', '')
534 classes_to_check = ['button', 'icon', 'logo']
535 tags_to_check = ['button', 'input']
536 return all([
537 'display:none' not in style,
538 src,
539 not any(s in var for var in [src, img.get('alt', ''), *parent_classes] for s in classes_to_check),
540 parent.name not in tags_to_check
541 ])
542
543 #Score an image for it's usefulness
544 def score_image_for_usefulness(img, base_url, index, images_count):

Callers 2

process_imageFunction · 0.85
process_imageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…