aboutsummaryrefslogtreecommitdiff
path: root/guidelines/wikipedia/imageCaption.js
blob: 621283042aefe203282090178ea64d42736a05a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
exports.name = "Images should contain a caption";
exports.description = "Images should contain a caption, either using the built-in image syntax or a secondary line of text.";

exports.rule = function(report) {
  $5('#mw-content-text img')
  // Exclude small images, which are probably icons.
  .filter(function(i, img) {
    var $img = $(img);
    return $img.width() > 50 || $img.height() > 50;
  })
  .each(function(i, img) {
    var $parent = $(img).parents(':not(a, td, tr, .thumbimage):first');
    var text    = $.trim($parent.text());
    if (!text) {
      report.warning("Does this image have a caption?", img);
    }
  });
};