Permalink
Browse files

update

  • Loading branch information...
1 parent 97f2dd0 commit 37f93b5cbdb1198fa47238beb13ded605c38a5f6 Andris Reinman committed May 25, 2012
Showing with 20 additions and 1 deletion.
  1. +20 −1 scripts/sanitize.js
View
@@ -32,8 +32,27 @@ page.open(phantom.args[0], function (status) {
page.evaluate(sanitizeDOM);
page.evaluate(function(){
+
+ // find largest image
+ var image,
+ width, height,
+ images = document.body.getElementsByTagName("p");
+
+ for(var i=images.length-1; i>=0; i--){
+ width = (Number(images[i].width) || 0) ;
+ height = (Number(images[i].height) || 0);
+ if(width > 30 && height > 30 && (!image || width + height > image.width + image.height)){
+ image = {
+ src: images[i].src,
+ width: Number(images[i].width) || 0,
+ height: Number(images[i].height) || 0
+ }
+ }
+ }
+
console.log(JSON.stringify({
- body: document.body.innerHTML
+ body: document.body.innerHTML,
+ image: image
}));
});

0 comments on commit 37f93b5

Please sign in to comment.