Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atom <logo> is cropped into a squared icon even if it should be 2:1 landscape according to specs #226

Closed
AlphaJack opened this issue Apr 24, 2024 · 3 comments

Comments

@AlphaJack
Copy link

Expected behavior

Feeder app shows my squared "icon.png" as feed icon

Actual behavior

Feeder app crops my landscape "logo.png" as feed icon

Steps to reproduce the behavior

  1. Have a feed with a squared icon and 2:1 logo, as per specs: https://validator.w3.org/feed/docs/atom.html#optionalFeedElements
  2. Use the Feeder app to subscribe to the feed.

I'm posting here because the Feeder author mentioned it's a gofeed behavior: spacecowboy/Feeder#270 (reply in thread)

@spacecowboy
Copy link
Contributor

To rephrase: the user wants icon to be prioritized before logo for atom feeds.

There is no way for a client to pick between them since gofeed picks one.

Personally I do not consider this a problem.

@mmcdole
Copy link
Owner

mmcdole commented Jan 2, 2025

This is a case where you might want to use a custom translator. The universal feed type needs to choose one field when mapping from format-specific fields (like Atom's icon and logo), but you can create your own translator to change this behavior.

The README shows how to use custom translators. You can implement the gofeed.Translator interface to customize how Atom feeds are translated into the universal feed type. This would let you prioritize icon over logo or even preserve both fields.

Here's a basic example:

type MyTranslator struct {
    *DefaultAtomTranslator
}

func (t *MyTranslator) Translate(feed interface{}) (*gofeed.Feed, error) {
    atomFeed := feed.(*atom.Feed)
    f, err := t.DefaultAtomTranslator.Translate(feed)
    if err != nil {
        return nil, err
    }
    
    // Prioritize icon over logo
    if atomFeed.Icon != "" {
        f.Image = &gofeed.Image{URL: atomFeed.Icon}
    } else if atomFeed.Logo != "" {
        f.Image = &gofeed.Image{URL: atomFeed.Logo}
    }
    
    return f, nil
}```

@mmcdole mmcdole closed this as completed Jan 2, 2025
@spacecowboy
Copy link
Contributor

Thanks for the example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants