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

Missing 'type="image/*"' attribute for image enclosures #37

Closed
jwaltonmedia opened this issue Apr 13, 2016 · 3 comments
Closed

Missing 'type="image/*"' attribute for image enclosures #37

jwaltonmedia opened this issue Apr 13, 2016 · 3 comments

Comments

@jwaltonmedia
Copy link

It looks like feedly.com will not parse image enclosure node as images without type="image/*". found this: http://help.campaignmonitor.com/topic.aspx?t=277

Adding this attribute fixes the issue.

@bonesoul
Copy link

bonesoul commented Apr 24, 2018

same here. can we get an updated version?

@gruberjl
Copy link

gruberjl commented Apr 30, 2018

Here's a quick and dirty fix:

const fs = require('fs')
const cheerio = require('cheerio')
const mime = require('mime-types')

const fixEnclosure = (rss) => {
  const getLocalPath = (url) => url.replace('http://gitbit.org', './docs')

  const $ = cheerio.load(rss, {xmlMode: true})
  $('enclosure').each((idx, el) => {
    const path = getLocalPath($(el).attr('url'))
    const stats = fs.statSync(path)
    $(el).attr('length', stats.size)
    $(el).attr('type ', mime.lookup(path))
  })

  return $.html()
}

const rss = fixEnclosure(feed.rss2())

@jpmonette
Copy link
Owner

Please, if this is still an issue, feel free to re-open using the New Feature Issue template. Thanks.

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

4 participants