From 533c6502f2ba4a17f802eb1cd31d33136c6007de Mon Sep 17 00:00:00 2001 From: Kyle Niewiada Date: Tue, 11 Apr 2017 11:14:13 -0400 Subject: [PATCH 1/3] Fix issue #183 image.itemtype --- lib/template.html | 9 +++++++++ spec/jekyll_seo_tag_spec.rb | 10 ++++++++++ 2 files changed, 19 insertions(+) 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 From 1125c1076737d9a11ad6704df71c60547f0d5b52 Mon Sep 17 00:00:00 2001 From: Kyle Niewiada Date: Tue, 11 Apr 2017 11:58:01 -0400 Subject: [PATCH 2/3] change wording --- spec/jekyll_seo_tag_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index aa1323f..48a338b 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -196,7 +196,7 @@ describe Jekyll::SeoTag do expect(output).to match(expected) end - it "outputs the default image JSON item" do + it "outputs the image JSON item" do expect(json_data["image"]).to eql("http://example.invalid/img/foo.png") end end @@ -230,7 +230,7 @@ describe Jekyll::SeoTag do expect(output).to match(expected) end - it "outputs the default image JSON object with dimensions" do + it "outputs the 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) From dfacea2a9c86486594f549ca6c3c89c359cc2f9a Mon Sep 17 00:00:00 2001 From: Kyle Niewiada Date: Tue, 11 Apr 2017 12:04:17 -0400 Subject: [PATCH 3/3] Appease lord RuboCop --- spec/jekyll_seo_tag_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 48a338b..230563d 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -231,7 +231,7 @@ describe Jekyll::SeoTag do end it "outputs the image JSON object with dimensions" do - expect(json_data["image"]["url"]).to eql("http://example.invalid/img/foo.png") + 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