aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jesse Hallett <jesse@galois.com>2013-12-23 14:33:03 -0800
committerGravatar Jesse Hallett <jesse@galois.com>2013-12-23 14:55:23 -0800
commit3de8afaa1a204aac019bc4404c9deecb64621b00 (patch)
treeeaf42842acce938c6d9cd85643875da7c4a7c738
parent62abc5c667896f7af216c4fa6643fc604b8b051f (diff)
Wikipedia guideline: images should contain a caption
-rw-r--r--guidelines/wikipedia/imageCaption.js18
-rw-r--r--guidelines/wikipedia/wikipedia.json1
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"
]
}