Dynamically adding Captions to images
I have a site where the author has included Amazon Affiliate links. They've done this by adding the URL to product images.
I'm wondering if there's a way to add a function that will automatically add a wp-caption below these images if they're linked to Amazon.
Basically the condition would need to be: if an href containing an image is linked to a domain including 'amazon', add a caption below that image that says "Buy Now". The caption would also have the same link as that image.
I've been able to do this with some hacky jQuery, but it doesn't always fire properly. I think there might be a better way...
Thanks