I am working on a WP website that uses an ecommerce plugin; amongst other things this plugin stores and retrieves product images. Trouble is that, if the product has no image assigned it returns an anchor tag with nothing in the text node as follows:
<a id="product_image_id" href="..."></a>
I’d like to stay away from messing with the core functions of the plugin so that I can stay on the upgrade path and would like to use PHP to check the returned string for an empty text node and replace it with a ‘no image available’ image like so:
<a id="product_image_id" href="..."><img src="..." /></a>
I’ve tried all manner of PHP sub string / replace functions without any success and have hit a wall.
Any help would be greatly appreciated!
For anyone interested, here is how I solved it:
I hope this helps some one!