Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6468875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:55:51+00:00 2026-05-25T05:55:51+00:00

I have a local intranet site I am developing on which I want to

  • 0

I have a local intranet site I am developing on which I want to display some rss feeds from other sites. Currently is is built on the Concrete5 CMS and I am using an RSS displayer plugin to display the feeds. The plugin uses SimplePie to parse the feed. By default, the plugin displays the entire RSS content. I’ve tweaked the plugin (SimplePie) to display only a title with link, date, and the first image in each post/entry.
I found this function that I pass $item->get_content() to in order to get the first image’s source:

function getFirstImage($text) {
    $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
$pattern = "/<img[^>]+\>/i";
preg_match($pattern, $text, $matches);
    $text = $matches[0];
return $text;
}
function scrapeImage($text) {

    $pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/'; 
    preg_match($pattern, $text, $link);
$link = $link[1];
$link = urldecode($link);
return $link;
}

It works fine, the problem is that some of the feeds have ads in them which are sometimes placed before the actual post content, therefore this function returns the url of an ad. Obviously these RSS ads are targeted at people who use rss readers, but for displaying them on a site, they are very annoying.

If I try to target exact tags besides <img> within preg_match() I feel it will only work for the specific feed that I’ve taken the tag from. (For example, if I try to use preg_match() to find only images inside <p> tags)

How can I get the first image from the actual post that isn’t an ad without having to change the code for each feed I want to display?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:55:51+00:00Added an answer on May 25, 2026 at 5:55 am

    I’m not sure if this would work for your situation but usually ad images come from a different domain or sub-domain than the regular content. You could try to filter out images based on the domain or sub-domain in the URL being different then the domain or sub-domain of the rss feed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have SharePoint with the local intranet link as http://shserver/Sites/LAPP/HR/LA . I want to
I have a new MVC application which integrates into a larger pre-existing intranet site.
I have a local intranet application which runs off a basic WAMP server in
We have an issue for our intranet site that is running in our local
I have my intranet app with windows authentication. On my local machine I run
I have local server for my site (i made it with XAMPP). How can
I have a local site (IIS6, although similar issue with a totally different site
I have the local file path as c:\new folder\pdf\today\k.pdf I want to replace the
I have an intranet site that our customer needs to access both internally and
I am building a local intranet web application which uses the current user's AD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.