Skip to main content

Hi there!

My client is looking to build an automation so that every time they send out a new mailchimp campaign, the campaign is added as a blog item in their webflow CMS - this is to avoid entering both manually.

 

I’ve connected Mailchimp new campaign as my trigger → sent through to a zapier formatter to remove the ‘unsubscribe’ and ‘company details’ which appear at the bottom of every mailchimp campaign → this feeds through to zapier formatter to extract the top image URL as the header image → this feeds through to Webflow and a new post is created.

 

Here’s the issue. Or for those that don’t want to watch the video; the image URL’s used in the mailchimp campaign are being pulled through as URL’s, not images. So the blog has an image URL above each section as opposed to the picture. How do I convert all links to images? or is there another workaround to this i’m not seeing?

Hi @BriansJWFishers 

You may need to wrap the image link URLs in a HTML img tag:

https://www.w3schools.com/tags/tag_img.asp


Hi @Troy Tessalone,

Thanks for this.

How would I achieve this through Zapier? Or is this something that would need to be done on the mailchimp end? 


@BriansJWFishers 

You may have to use a custom Code step to parse thru the data from Mailchimp to find strings that match a URL, then update those found substrings to be wrapped in an image tag.

https://zapier.com/apps/code/help

 

Zapier has an AI help in the Code step:

https://help.zapier.com/hc/en-us/articles/15666688064013-Generate-a-Code-step-using-AI-Beta


Thanks @Troy Tessalone - some python code did the trick.

 

For anyone searching in the future, this is the code;

# Regular expression to find image URLs (common image file extensions) image_pattern = r'(http?://:^\s]+?\.(?:gif|jpg|jpeg|png|bmp|svg))'

# Replace image URLs with HTML image tags modified_text = re.sub(image_pattern, r'<img src="\1" alt="Image" />', text)

# Prepare the output with the modified text output = {'modified_text': modified_text}


That’s great news @BriansJWFishers! A huge thanks to Troy for pointing you in the right direction!

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗