Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ client.keywords # keywords from meta tag, as array
client.charset # page charset from meta tag, as string
client.description # returns the meta description, or the first long paragraph if no meta description is found
client.image # Most relevant image, if defined with og:image
client.imageWidth # Image width, if defined with og:image:width
client.imageHeight # Image height, if defined with og:image:height
client.images # array of strings, with every img found on the page as an absolute URL
client.feeds # Get rss or atom links in meta data fields as array
client.ogTitle # opengraph title
Expand Down
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,30 @@ MetaInspector.prototype.getImage = function()
return this;
}

MetaInspector.prototype.getImageWidth = function()
{
debug("Parsing page image width based on the Open Graph image width");

if(!this.imageWidth)
{
this.imageWidth = this.parsedDocument("meta[property='og:image:width']").attr("content");
}

return this;
}

MetaInspector.prototype.getImageHeight = function()
{
debug("Parsing page image height based on the Open Graph image height");

if(!this.imageHeight)
{
this.imageHeight = this.parsedDocument("meta[property='og:image:height']").attr("content");
}

return this;
}

MetaInspector.prototype.getImages = function()
{
debug("Parsing page body images");
Expand Down Expand Up @@ -283,6 +307,8 @@ MetaInspector.prototype.initAllProperties = function()
.getLinks()
.getDescription()
.getImage()
.getImageWidth()
.getImageHeight()
.getImages()
.getFeeds()
.getOgTitle()
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/fastandfurious7-film.com.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="FAST & FURIOUS 7 | SITE OFFICIEL DU FILM | MAINTENANT EN BLU-RAY, DVD ET TELECHARGEMENT DEFINITIF HD"/>
<meta property="og:image" content="images/fb.jpg"/>
<meta property="og:image:width" content="800"/>
<meta property="og:image:height" content="600"/>
<meta property="og:description" content="Continuing the global exploits in the unstoppable franchise built on speed, Vin Diesel, Paul Walker and Dwayne Johnson lead the returning cast of Fast & Furious 7."/>
<meta itemprop="name" content="FAST & FURIOUS 7 | SITE OFFICIEL DU FILM | MAINTENANT EN BLU-RAY, DVD ET TELECHARGEMENT DEFINITIF HD"/>
<meta itemprop="description" content="Continuing the global exploits in the unstoppable franchise built on speed, Vin Diesel, Paul Walker and Dwayne Johnson lead the returning cast of Fast & Furious 7."/>
Expand Down Expand Up @@ -2132,7 +2134,7 @@
<iframe class="fallbackYT" id="youtube_player" width="900" height="515" src="http://www.youtube.com/embed/videoseries?list=PLzzsAEt-XPvv5QavTXpXbDibZP6PjQpEn&enablejsapi=1&version=3&playerapiid=ytplayer" allowfullscreen="true" allowscriptaccess="always" frameborder="0"></iframe>
</div>
</div>
<!-- /VIDEO MODAL —>
<!-- /VIDEO MODAL —>



Expand Down
22 changes: 22 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,28 @@ describe('metainspector', function(){
client.fetch();
});

it('should have a og:image:width', function(done){
client = new MetaInspector("http://www.fastandfurious7-film.com");

client.once("fetch", function(){
client.imageWidth.should.equal("800");
done();
});

client.fetch();
});

it('should have a og:image:height', function(done){
client = new MetaInspector("http://www.fastandfurious7-film.com");

client.once("fetch", function(){
client.imageHeight.should.equal("600");
done();
});

client.fetch();
});

it('should have a og:description', function(done){
client = new MetaInspector("http://www.fastandfurious7-film.com");

Expand Down