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

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

Open
siwise opened this issue Aug 10, 2016 · 10 comments

Comments

@siwise
Copy link

siwise commented Aug 10, 2016

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.

@sdepold
Copy link
Owner

sdepold commented Aug 12, 2016

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
#115, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAE1O-CZWLJY2Q1SKTshLS8SpgeLc1nmks5qeR7rgaJpZM4JgqZx
.

@siwise
Copy link
Author

siwise commented Aug 13, 2016

@sdepold
Copy link
Owner

sdepold commented Aug 13, 2016

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
Copy link
Owner

sdepold commented Aug 13, 2016

Here we go :) sdepold/feedrapp#48

@sdepold
Copy link
Owner

sdepold commented Aug 13, 2016

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
Copy link
Owner

sdepold commented Aug 13, 2016

Please let me know if this works for you :)

@meancode
Copy link

@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.

@sdepold
Copy link
Owner

sdepold commented Sep 13, 2016

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
})```

@meancode
Copy link

@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
Copy link

@sdepold nevermind on the truncated body.

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