diff options
Diffstat (limited to 'guidelines/wikipedia')
-rw-r--r-- | guidelines/wikipedia/imageCaption.js | 18 | ||||
-rw-r--r-- | guidelines/wikipedia/wikipedia.json | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/guidelines/wikipedia/imageCaption.js b/guidelines/wikipedia/imageCaption.js new file mode 100644 index 0000000..6212830 --- /dev/null +++ b/guidelines/wikipedia/imageCaption.js @@ -0,0 +1,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); + } + }); +}; diff --git a/guidelines/wikipedia/wikipedia.json b/guidelines/wikipedia/wikipedia.json index f53febc..bb36baa 100644 --- a/guidelines/wikipedia/wikipedia.json +++ b/guidelines/wikipedia/wikipedia.json @@ -15,5 +15,6 @@ , "floatSandwiches.js" , "spaceBetweenListItems.js" , "imageAlt.js" + , "imageCaption.js" ] } |