jquery-rss icon indicating copy to clipboard operation
jquery-rss copied to clipboard

wordpress.com adds tracking pixel (gif) that teaserImage pulls instead of post image

Open siwise opened this issue 8 years ago • 10 comments

Hi, Thanks for a great tool! As stated, wordpress.com add a crazy tracking pixel as an image for every post. There is no way to disable this "feature" on wordpress.com and all themes seem to enable this "feature".

Is there any simple way of forcing teaserImage and teaserImageUrl to call the second or third image? Hoping this would get around this stupid tracking pixel issue.

I have tried messing with different number combinations of this line but haven't found one that works.

teaserImageUrl: (function (entry) { try { return entry.content.match(/(<img.*?>)/gi)[0].match(/src="(.*?)"/)[1]; }

Thanks for your help!


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

siwise avatar Aug 10 '16 00:08 siwise

Can you paste feed url? siwise [email protected] schrieb am Mi., 10. Aug. 2016 um 02:44:

Hi, Thanks for a great tool! As stated, wordpress.com add a crazy tracking pixel as an image for every post. There is no way to disable this "feature" on wordpress.com and all themes seem to enable this "feature".

Is there any simple way of forcing teaserImage and teaserImageUrl to call the second or third image? Hoping this would get around this stupid tracking pixel issue.

I have tried messing with different number combinations of this line but haven't found one that works.

teaserImageUrl: (function (entry) { try { return entry.content.match(/(<img.?>)/gi)[0].match(/src="(.?)"/)[1]; }

Thanks for your help!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sdepold/jquery-rss/issues/115, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE1O-CZWLJY2Q1SKTshLS8SpgeLc1nmks5qeR7rgaJpZM4JgqZx .

sdepold avatar Aug 12 '16 04:08 sdepold

Tried with https://asijnews.com/feed/ and https://asijnews.com/feed/?mrss=off

siwise avatar Aug 13 '16 02:08 siwise

For whatever reason wordpress is not embedding the images into the post description itself. Instead it puts it outside of the description as media tags. So what one would need to do is to go into the feedrapp and add support for them their. https://github.com/sdepold/feedrapp

sdepold avatar Aug 13 '16 06:08 sdepold

Here we go :) https://github.com/sdepold/feedrapp/pull/48

sdepold avatar Aug 13 '16 06:08 sdepold

Tada:

jQuery("#rss-feeds").empty().rss("https://asijnews.com/feed/", { 
  entryTemplate: "<img src='{img}'>", 
  tokens: {
    img: function (entry, tokens) { return entry.thumbnail; }
  }, 
  limit: 10
})

sdepold avatar Aug 13 '16 06:08 sdepold

Please let me know if this works for you :)

sdepold avatar Aug 13 '16 06:08 sdepold

@sdepold When I try this, it renders the following:

<img src="undefined">

What am I doing wrong? I am not using WP, BTW. I just want to be able to bring in the media image.

meancode avatar Sep 12 '16 20:09 meancode

can you run this code? It prints the content of the entry. please paste one of the entries here. It works for me nicely. You are not running your own version of feedrapp I assume?

jQuery("#rss-feeds").empty().rss("https://asijnews.com/feed/", { 
  entryTemplate: "<img src='{img}'>", 
  tokens: {
    img: function (entry, tokens) { console.log(JSON.stringify(entry, null, 2)); return entry.thumbnail; }
  }, 
  limit: 10
})```

sdepold avatar Sep 13 '16 04:09 sdepold

@sdepold You are correct, we are not running our own feedrapp. We may do that in the future, not sure.

Okay, it brought in the image using that feed. I will paste one of the JSON responses below.

Question: Is it only looking for media:thumbnail? Or does it account for other xml tags? Such as:

<media:content url="https://static01.nyt.com/images/2016/09/13/us/13FD-TRUMP-alt/13FD-TRUMP-1473720822075-moth.jpg" medium="image" height="151" width="151"/>

Question 2: What is the best way to limit the text that is displayed from bodyPlain?

Thanks so much for the response!

Here is the JSON:

{
  "title": "Welcome Back to School",
  "link": "https://asijnews.com/2016/09/07/welcome-back-to-school/",
  "content": "With a typhoon fast approaching Japan, it looked like the first day of school for all divisions on Wednesday, Aug 31 might have been rained out. Luckily for all, the typhoon headed up the coast and students arrived to campus for a sunny start. For many, the first chance to catch up with friends, or make new &#8230; <a href=\"https://asijnews.com/2016/09/07/welcome-back-to-school/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Welcome Back to&#160;School</span></a><img alt=\"\" border=\"0\" src=\"https://pixel.wp.com/b.gif?host=asijnews.com&#038;blog=43943841&#038;post=9901&#038;subd=asijnews&#038;ref=&#038;feed=1\" width=\"1\" height=\"1\" />",
  "contentSnippet": "With a typhoon fast approaching Japan, it looked like the first day of school for all divisions on Wednesday, Aug 31 mig",
  "publishedDate": "2016-09-07T05:37:00.000Z",
  "categories": [
    {
      "name": "Elementary School"
    },
    {
      "name": "High School"
    },
    {
      "name": "Middle School"
    },
    {
      "name": "Buses"
    },
    {
      "name": "First Day of School"
    },
    {
      "name": "Student Perspective"
    },
    {
      "name": "Students"
    }
  ],
  "author": "asijnews",
  "thumbnail": "https://asijnews.files.wordpress.com/2016/09/0y3a0987.jpg"
}

meancode avatar Sep 13 '16 14:09 meancode

@sdepold nevermind on the truncated body.

meancode avatar Sep 13 '16 16:09 meancode