Class: ImageCheck
- Inherits:
-
HTML::Proofer::CheckRunner
- Object
- HTML::Proofer::CheckRunner
- ImageCheck
- Defined in:
- lib/html/proofer/checks/images.rb
Instance Attribute Summary
Attributes inherited from HTML::Proofer::CheckRunner
#alt_ignores, #empty_alt_ignore, #external_urls, #href_ignores, #hydra_opts, #issues, #options, #parallel_opts, #path, #src, #typhoeus_opts, #url_ignores, #validation_opts
Instance Method Summary collapse
Methods inherited from HTML::Proofer::CheckRunner
#add_issue, #add_path_for_url, #add_to_external_urls, checks, #initialize
Constructor Details
This class inherits a constructor from HTML::Proofer::CheckRunner
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/html/proofer/checks/images.rb', line 26 def run @html.css('img').each do |node| img = ImageCheckable.new(node, self) line = node.line next if img.ignore? # screenshot filenames should return because of terrible names next add_issue("image has a terrible filename (#{img.src})", line) if img.terrible_filename? # does the image exist? if img.missing_src? add_issue('image has no src or srcset attribute', line) else if img.remote? add_to_external_urls(img.src, line) else add_issue("internal image #{img.src} does not exist", line) unless img.exists? end end if img.alt.nil? || (img.empty_alt_tag? && !img.ignore_empty_alt?) add_issue("image #{img.src} does not have an alt attribute", line) end end external_urls end |