how to display only image in simplepie when using rss feed.I am using simplepie but enable to extract only image from rss.How to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Considering certain feed structures are different, there is not an explicit way of doing this that I know of. This is how I was able to do it.First check out this article:
How to Display Thumbnail from WordPress RSS feed using SimplePie?
I was able to copy and paste the code and make some minor changes
I was not using WordPress, but it helped give me an idea of what needed to be done.
Insert this code after feed->init();
Now you want to call the functions so it searches the description, or in my case the content, to find the img tag and structure the output correctly. This is what my code looked like:
It may take some buggin, but once you know where your img tag exists in the feed, you can get simplepie to parse the feed and the function will find the tag and format so it is html ready.
To only pull one post, you can edit your loop:
The first number (0) is the starting point, 0 being the latest posts. The second number (1) is how many posts to pull. Since you only want one image, you want that number to be 1.