diff --git a/lib/template.html b/lib/template.html index e3375c2..e0f673f 100755 --- a/lib/template.html +++ b/lib/template.html @@ -223,7 +223,16 @@ {% endif %} {% if seo_page_image %} + {% if page.image.height && page.image.width %} + "image": { + "@type": "ImageObject", + "url": {{ seo_page_image | jsonify }}, + "height": {{ page.image.height | jsonify }}, + "width": {{ page.image.width | jsonify }} + }, + {% else %} "image": {{ seo_page_image | jsonify }}, + {% endif %} {% endif %} {% if page.date %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 546c2c2..aa1323f 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -195,6 +195,10 @@ describe Jekyll::SeoTag do expected = %r!! expect(output).to match(expected) end + + it "outputs the default image JSON item" do + expect(json_data["image"]).to eql("http://example.invalid/img/foo.png") + end end context "when given a facebook image" do @@ -225,6 +229,12 @@ describe Jekyll::SeoTag do expected = %r!! expect(output).to match(expected) end + + it "outputs the default image JSON object with dimensions" do + expect(json_data["image"]["url"]).to eql("http://example.invalid/img/foo.png") + expect(json_data["image"]["height"]).to eql(1) + expect(json_data["image"]["width"]).to eql(2) + end end end