Skip to content

Commit

Permalink
Added fallback to atom icon when atom logo is missing (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Feb 23, 2024
1 parent 38e4aa4 commit b187685
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testdata/translator/atom/feed_image_-_atom10_feed_icon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"image": {
"url": "http://example.org/icon.jpg"
},
"items": [],
"feedType": "atom",
"feedVersion": "1.0"
}
6 changes: 6 additions & 0 deletions testdata/translator/atom/feed_image_-_atom10_feed_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--
Description: feed icon
-->
<feed xmlns="http://www.w3.org/2005/Atom">
<icon>http://example.org/icon.jpg</icon>
</feed>
1 change: 1 addition & 0 deletions testdata/translator/atom/feed_image_-_atom10_feed_logo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Description: feed logo
-->
<feed xmlns="http://www.w3.org/2005/Atom">
<logo>http://example.org/logo.jpg</logo>
<icon>http://example.org/icon.jpg</icon>
</feed>
4 changes: 4 additions & 0 deletions translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ func (t *DefaultAtomTranslator) translateFeedImage(atom *atom.Feed) (image *Imag
feedImage := Image{}
feedImage.URL = atom.Logo
image = &feedImage
} else if atom.Icon != "" {
feedImage := Image{}
feedImage.URL = atom.Icon
image = &feedImage
}
return
}
Expand Down

0 comments on commit b187685

Please sign in to comment.