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 6917905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:47:27+00:00 2026-05-27T09:47:27+00:00

I have a lot of user generated content that has inline images in it,

  • 0

I have a lot of user generated content that has inline images in it, in this style:

<img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb2
/ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1hwLJoExKcpp
V0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjd7sJAgVGoEgAwXEQA7" 
width="16" height="14" alt="embedded folder icon">

Some of the images are gif, some are png, but it is possible they are of other image types, too.

I’d like to be able to remove inline images like this with PHP. I’m guessing that the way to do it would be a regular expression, even though overuse of regex seems to be frowned on in the Stack Overflow community as it is often used in place of other tools that work better and are designed for a specific purpose.

However, for this scenario I could think of no other tools that might do the job other than strip_tags, but I do want to keep images that are not encoded inline.

So, how can I use a regular expression to filter out just inline images with PHP? Or, if there is a better tool to do this, what is it?

  • 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-27T09:47:27+00:00Added an answer on May 27, 2026 at 9:47 am

    A regular expression sounds fine to me. Just have it match data:image/gif and other types of images you want to remove if and only if they occur within an img tag.

    Here’s a starting point, expand it to your liking:

    <img[^>]* src=['"]?data:image/gif[^>]*>
    

    Make sure to run it with the ignore case flag and test the hell out of it before you put it live.

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

Sidebar

Related Questions

I have a a user that has a lot of tables against their account.
I have a web application that stores a lot of user generated files. Currently
My site has user generated content. I noticed that if the user has quotes
I have a page that has a form and a generated content area that
I've been looking at a lot of iOS user interfaces that have been customized.
Hi all I have a variable that is a YouTube url that is user-generated.
I have images (PNG) that are generated dynamically and will be embedded in websites
I have configured Tridion for User Generated content, and created a web page using
I have found a lot of information on using UIImagePickerController to let the user
A lot of JavaScript libraries have user interface widgets. Usually they are created after

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.