aboutsummaryrefslogtreecommitdiff
path: root/guidelines/wikipedia/src/imageCaption.js
diff options
context:
space:
mode:
authorGravatar Jesse Hallett <jesse@galois.com>2014-01-06 10:50:22 -0800
committerGravatar Jesse Hallett <jesse@galois.com>2014-01-06 11:15:49 -0800
commit55cd32bfaf9ed5bc5418751369e46fa1d7f098e8 (patch)
treec5759cf75241a4e6bc0fb31596b69c59a9bdc6b5 /guidelines/wikipedia/src/imageCaption.js
parent0a47eab285bf1c04f48a2d6d84838a98807c8c69 (diff)
Moves rule files to src/
Diffstat (limited to 'guidelines/wikipedia/src/imageCaption.js')
-rw-r--r--guidelines/wikipedia/src/imageCaption.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/guidelines/wikipedia/src/imageCaption.js b/guidelines/wikipedia/src/imageCaption.js
new file mode 100644
index 0000000..6212830
--- /dev/null
+++ b/guidelines/wikipedia/src/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);
+ }
+ });
+};