From 3de8afaa1a204aac019bc4404c9deecb64621b00 Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Mon, 23 Dec 2013 14:33:03 -0800 Subject: Wikipedia guideline: images should contain a caption --- guidelines/wikipedia/imageCaption.js | 18 ++++++++++++++++++ guidelines/wikipedia/wikipedia.json | 1 + 2 files changed, 19 insertions(+) create mode 100644 guidelines/wikipedia/imageCaption.js 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" ] } -- cgit v1.2.3