Jump to content

Find linked and unlinked image tags


spuds

Recommended Posts

thump thump thump ... the sound of my head on the desk .... I just can't figure this one out !

 

I need a regex / function that will read in a string of html and find all img tags, yes that part is easy, but If the img tag is inside of an <a href tag then I also need that tag returned if there is one or blank if there is none.

 

What I'm ultimately trying to do is read a post and find the img tags, if its a stand-alone tag then I will wrap it in an anchor tag and if its already in an anchor tag I'm going to add to the class of the tag.  In the end I'll be able to run some Javascript on the page and do so client side work on all images  that are wrapped a certain way.

 

help is greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/197830-find-linked-and-unlinked-image-tags/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.