Skip to content

Commit

Permalink
Merge pull request #104 from jekyll/pr/image
Browse files Browse the repository at this point in the history
Merge pull request 104
  • Loading branch information
jekyllbot committed Mar 22, 2016
2 parents 680ded5 + 9ac99bd commit e25c27d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ There are several ways to convey author-specific information. Author information
author: benbalter
```

* `image` - URL of an image that is representative of the post.

### Meta tags

The plugin exposes a helper tag to expose the appropriate meta tags to support automated discovery of your feed. Simply place `{% feed_meta %}` someplace in your template's `<head>` section, to output the necessary metadata.
Expand Down
8 changes: 8 additions & 0 deletions lib/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
{% if post.excerpt and post.excerpt != empty %}
<summary>{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
{% endif %}

{% assign post_image = post.image %}
{% if post_image %}
{% unless post_image contains "://" %}
{% assign post_image = post_image | prepend: url_base | xml_escape %}
{% endunless %}
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="{{ post_image }}" />
{% endif %}
</entry>
{% endunless %}
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/_posts/2013-12-12-dec-the-second.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
excerpt: "Foo"
image: "/image.png"
---

# December the twelfth, actually.
1 change: 1 addition & 0 deletions spec/fixtures/_posts/2014-03-02-march-the-second.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
image: "https://cdn.example.org/absolute.png"
---

March the second!
5 changes: 5 additions & 0 deletions spec/jekyll-feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
expect(contents).not_to match /Liquid is not rendered\./
end

it "includes the item image" do
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/image.png" />')
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://cdn.example.org/absolute.png" />')
end

context "parsing" do
let(:feed) { RSS::Parser.parse(contents) }

Expand Down

0 comments on commit e25c27d

Please sign in to comment.