Recently Amazon announced they are shutting down SiteStripe Image and Text+Image feature on their Affiliate portal. We had a request from one of our customers how they could bulk update hundreds of their posts containing SiteStripe image links from Amazon. It is a tedious task to manually download each image, save to media library and update it via the affiliate HTML code in your post.
(Note: This method only replaces Image links but not Text+Image, we will be working on a solution for Text+Image links soon)
Prerequisites
- You must know how to use file manager to create files and folders
- You must know how to replace text in PHP code
- Please take a full backup of your site before running such scripts
We will be creating a PHP script and execute it on browser to do bulk search and replace operation. The script is designed to do the following:
- It goes through all your posts
- Scans the links containing URL amazon.com
- Searches for images within the link that have their URL as amazon-adsystem.com
- Downloads the images to a folder called amazon_images on your server
- Replaces the Amazon images with downloaded images
Step 1: Create a PHP file
You will need to access your web host File Manager via FTP or cPanel. Once you are in your file manager, you can create a PHP script (file) and give it a name, for example: test.php. This file should be created in your WordPress root folder (the folder containing your wp-config.php file)
Edit the test.php file and add the code below within it:
Save the file.
Step 2: Time to execute the code
Open a new tab in your browser and run the test.php script by accessing it directly: For example: https://wporbit.net/test.php
Let the script run, could take a while depending on how many links you have.
Congratulations! You’ve now replaced all Amazon Image links on your site.
We understand this code might not be perfect or suit every site, feel free to comment down below if you face any issues or hire us to do it for you.
Leave a Reply