Skip to content

Commit

Permalink
Allow absolute URLs for image
Browse files Browse the repository at this point in the history
  • Loading branch information
pathawks committed Mar 21, 2016
1 parent e920c03 commit 26a0a5e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Additionally, the plugin will use the following values, if present in a post's Y
* `author` - The author of the post, e.g., "Dr. Jekyll". If none is given, feed readers will look to the feed author as defined in `_config.yml`. Like the feed author, this can also be an object.

* `image` - URL of an image that is representative of the post.
**Note:** URL must be relative to the site root, eg: `/images/example.png`

### Meta tags

Expand Down
8 changes: 6 additions & 2 deletions lib/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@
<summary>{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
{% endif %}

{% if post.image %}
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="{{ post.image | prepend: url_base | xml_escape }}" />
{% 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 %}
Expand Down
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!
1 change: 1 addition & 0 deletions spec/jekyll-feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@

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
Expand Down

0 comments on commit 26a0a5e

Please sign in to comment.