Class: Images
- Inherits:
-
HTML::Proofer::Checks::Check
- Object
- HTML::Proofer::Checks::Check
- Images
- Defined in:
- lib/html/proofer/checks/images.rb
Instance Attribute Summary
Attributes inherited from HTML::Proofer::Checks::Check
#additional_alt_ignores, #additional_href_ignores, #external_urls, #issues, #options, #path, #src
Instance Method Summary collapse
Methods inherited from HTML::Proofer::Checks::Check
#add_issue, #add_to_external_urls, #initialize, #output_filenames, subclasses
Constructor Details
This class inherits a constructor from HTML::Proofer::Checks::Check
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 |
# File 'lib/html/proofer/checks/images.rb', line 26 def run @html.css("img").each do |i| img = Image.new i, "image", self next if img.ignore? # screenshot filenames should return because of terrible names next self.add_issue "image has a terrible filename (#{img.src})" if img.terrible_filename? # does the image exist? if img.missing_src? self.add_issue "image has no src attribute" else if img.remote? add_to_external_urls img.src else self.add_issue("internal image #{img.src} does not exist") unless img.exists? end end # check alt tag self.add_issue "image #{img.src} does not have an alt attribute" unless img.valid_alt_tag? end external_urls end |